I use this code to display the 3D coordinates in the game screen, however they are displayed to four digits ie. 27.5693. My question is, can I lessen this to say… 27.5 ?
GUI.Label(Rect(10, 10, 500, 100), " X = " + transform.position.x + " Y = " + transform.position.y + " Z = " + transform.position.z);
You can use:
transform.position.x.ToString("0.0")
for one decimal digit. btw you can simply use ToString on the whole position to print all 3 components at once. The format string will be applied on each component:
transform.position.ToString("0.0")
The xyz values from the Vector3 are just regular C# floats and as such standard C# formatting is available
Example:
GUI.Label(Rect(10, 10, 500, 100), " X = " + transform.position.x.ToString("F1") + " Y = " + transform.position.y.ToString("F1") + " Z = " + transform.position.z.ToString("F1"));
Will display the X, Y and Z values to 1 decimal place.