Changing the angle of an object

When I change the angle of an object from an input box that I made, let’s say that I put 180.

the object is only supposed to rotate in the X axis from the transform, so I set it like this:

int ang = int.Parse (angle.GetComponent<InputField> ().text);
TargetPart.localRotation = Quaternion.Euler (  new Vector3( ang,0,0 )  );

but when I look at the transform of the object in the unity UI, the angles are:

x:-5.008956e-06
y:180
z:180

the same happens if I input any angle that is bigger than 90.

Now my problem is:
How can I get the real angle of the object?
If I rotate it to 180 and the transform values changed and aren’t 180, how can I know that it’s 180? because the inputbox then changes the text from 180 to -5.008956e-06 and I need it to display 180 instead of -5.008956e-06

Thanks for your time!

Internally Unity does not store angles for rotations. Instead it stores them as a four-element structure known as a Quaternion.

Therefore the actual .eulerAngles for display at any moment are derived from the values of the Quaternion, and hence must be simplified, since the four Quat numbers cannot be unambiguously displayed in x,y,z (3 numbers).

If you want to only spin on a given axis, you will always have more success if you make a new third independent variable (let’s call that variable “facingDirection”) and only modify that value directly. Every time that value changes you would remake the Quaternion, using that value to “drive” the axis you want to rotate. And at any time you can always display facingDirection for your own purposes.