get position of mouse click unity code example

Example 1: unity get mouse position

Vector3 worldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

Example 2: how to find the mouse position unity

Vector2 mousePosition = new Vector2(Input.mousePosition.x, Input.mousePosition.y);

Example 3: unity mouse click position

Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

RaycastHit hit = new RaycastHit();

if (Physics.Raycast(ray, out hit))
{
	return hit.point;
}

Example 4: unity mouse click screen

var cameraloc:Camera; 
var mousePos:Vector3; 
var worldPos:Vector3; 
cameraloc = GameObject.Find("Camera").GetComponent(Camera); 
mousePos = Input.mousePosition; 
worldPos = cameraloc.ScreenToWorldPoint(mousePos);