how to do a script for: when i leftclick on mouse on one location it will display the location Coordinates X adn Y
Thx to LoONuhtiK, it is soloved,for those who need this,below
private var hitPos : Vector3 ;
private var hitObjectPos : Vector3 ;
private var hit : RaycastHit ;
function Update(){
if(Input.GetMouseButtonDown(0)){
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition) ;
if(Physics.Raycast(ray , hit)){
hitPos = hit.point ;
hitObjectPos = hit.transform.position ;
}
}
}
//I guess you’re wanting to use GUI to display this stuff???
function OnGUI(){
//The world position of the ray’s contact point->
GUI.Label(Rect(5,50,200,50),hitPos+ “”) ;
}
function Update(){
if(Input.GetButtonDown(“Fire1”))
Debug.Log("x coordinate : " + Input.mousePosition.x + “y coordinate :” + Input.mousePosition.y);
}
}
Add the script to the camera or any gameobject in the scene.