- Home /
Show Vector3 full float value in Debug
Here's the code:
 float f = 1.234567f;
 Vector3 v3 = new Vector3(f,f,f);
 Debug.Log(v3);
The Console Show: (1.2,1.2,1.2) but I want it to show the full decimal like:(1.234567,1.234567,1.234567), How to show it?
Answer by CHPedersen · Oct 04, 2011 at 06:18 AM
When you pass a vector to Debug.Log, I suspect Debug.Log calls the Vector's ToString()-method for you, in order to make a string value out of the argument that it can write to the console. And the way Vector3.ToString() is implemented simply rounds the values to 1 decimal.
To get around this issue, you can either pass in the vector's coordinates individually, or you can use the overload of ToString that accepts a format, to determine how many decimal points you want the vector represented in. You can use it like this, for example:
 Vector3 point = new Vector3(0.9887f, 1.56789f, 3.09273475f);
 Debug.Log(point.ToString("F4"));
Here, the F means you're talking about Fixed-point, and the 4 means you want 4 decimals. You can pass in any number instead of 4. See http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx for further information on what to pass to ToString(string format).
Damn auto round, it scared me for a moment there, thanks for clearing this up CHPedersen.
good to know thanks, but how would you fix it in the mouseover tooltip kind of display in monodevelop?
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                