- Home /
Float output being rounded when unintended
So the short of it is this:
uvs[
0.0, 0.0 0.3, 0.0 0.0, 1.0 0.3, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.0, 0.0 0.3, 0.0 0.0, 1.0 0.3, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.0, 0.0 0.3, 0.0 0.0, 1.0 0.3, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.0, 0.0 0.3, 0.0 0.0, 1.0 0.3, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.3, 0.0 0.5, 0.0 0.3, 1.0 0.5, 1.0
0.0, 0.0 0.3, 0.0 0.0, 1.0 0.3, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.0, 0.0 0.3, 0.0 0.0, 1.0 0.3, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.0, 0.0 0.3, 0.0 0.0, 1.0 0.3, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.0, 0.0 0.3, 0.0 0.0, 1.0 0.3, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0
0.5, 0.0 0.8, 0.0 0.5, 1.0 0.8, 1.0]
I've succeeded in making a room dynamically with multiple materials so I can specify different textures and/or UVs as necessary on a single mesh. When getting the output of the UVs though and checking how they're laid out, rather than getting (in the first line) 0.0,0.0 0.25,0.0 0.0,1.0 0.25,1.0
, I get the above. Why is my output being rounded off? This is seriously screwing with my OCD. It seems like the actual correct 0.25 is being used in the array, because the textures are being displayed correctly with no clipping or bleeding, but if it wasn't and I needed the exact numbers to be displayed this would be crippling to my debugging.
I'm using C# by the way. Why is it doing this? To get this output I am adding a Vector2 to a string to compile the full output after everything is set up. Is this some wonky Vector2 + string interaction?
Answer by Cherno · Sep 23, 2014 at 12:21 PM
The numbers are in fact not rounded internally, but by default Unity shows these numbers rounded to one digit after the comma. You have to print each float in the V2 seperately for the real number to show. See also this thread:
Thanks, I tried searching for a similar question before, but I couldn't a similar problem. Sucks that it rounds though. >/