- Home /
Single number coordinates display
Hi, I'm displaying the camera World coordinates using the below code which works well but it displays a string of decimals. How can I reduce the string to single Numbers, thanks?
function OnGUI () { GUI.Label (Rect (10,10,500,100), " X= " + transform.position.x + " Y= " + transform.position.y + " Z= " + transform.position.z); }
Answer by Aydan · Apr 22, 2011 at 02:49 AM
Heres What I would do
private var xPosition : int; private var yPosition : int; private var zPosition : int;
function Update () { xPosition = transform.position.x; yPosition = transform.position.y; zPosition = transform.position.z; }
function OnGUI () { GUI.Label (Rect (10,30,500,100), " X= " + xPosition + " Y= " + yPosition + " Z= " + zPosition); }
So how will we do if the camera is moving,and when you click leftmouse down on a location,then it will display the clicked location coordinates