detect click position unity code example
Example 1: 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 2: 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);