Rotation value set in code does not match rotation value in the scene

I have set rotation value for a mesh like mesh.rotation.y = 5, but in the inspector, I get some value like this, I guess it’s because the rotationQuaternion, so I set the mesh.rotationQuaternion = null, but still get the same value in inspector, any idea what happens here

Update: I add Tools.ToRadians, it works as expected

It is confusing, but the inspector is in degrees and the mesh.rotation.y is in radians.

This is what you want:

mesh.rotation.y = (5/180) * Math.PI

So when you say:

mesh.rotation.y = 5

You are saying 5 / 3.14159 is 1.59155 radians.

Multiply it by 180 degrees per radian and you get 286.48 degrees.


You can force the Inspector to NOT convert to degree right here: