Vector3 worldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector2 mousePosition = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
void Update()
{
Vector3 mousePos = Input.mousePosition;
}
}
//In 2d/UI you can move the object to your mouse position by writing this in a script and then adding it to the object you want to be at the mouse position also put it in the void update spot
transform.position = Input.mousePosition;
//or in 3d
transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition)
Vector2 screenPosition = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
Vector2 worldPosition = Camera.main.ScreenToWorldPoint(screenPosition);