I am currently really confused regarding how rotation (and eulerAngles) work in Unity, and I feel like I am missing something fundamental.
I have a game object Emma, which has a script that constantly prints out the rotation (mainObject points to the Emma object):
"emma1 x=" + this.transform.eulerAngles.x + " y=" + this.transform.eulerAngles.y + " z=" + this.transform.eulerAngles.z);
"emma2 x=" + mainObject.transform.rotation.eulerAngles.x + " y=" + mainObject.transform.rotation.eulerAngles.y + " z=" + mainObject.transform.rotation.eulerAngles.z);
"emma3 x=" + mainObject.transform.rotation.x + " y=" + mainObject.transform.rotation.y + " z=" + mainObject.transform.rotation.z);
"emma4 x=" + mainObject.transform.localEulerAngles.x + " y=" + mainObject.transform.localEulerAngles.y + " z=" + mainObject.transform.localEulerAngles.z);
In the editor, I have rotated Emma to x=235 y=20 z=70.
However, the output becomes x=305 y=200 z=250.
Regardless how I rotate Emma the editor values makes sense for me, but the print output is understandable for me.
Another example is editor x=250 y=180 z=100 but the output becomes x=290 y=5 z=280.

Even if I rotate one axis in the editor, for example x in the script, all 3 can change (x, z, y) which makes no sense to me.
My fundamental problem is; I want, via scripting, be able to rotate Emma towards a specific direction (like towards a door in the flat). I can figure out the values by rotating Emma in the editor, but if I am not able to apply those values via scripting, then how else would one do it.
So my questions are:
- Why do they differ? I read somewhere that the editor shows the
localEulerAnglesbut apparently this is not true. - How do I print in a script the values that are shown in the editor? Am I not using the correct functions?
- If I want a specific direction shown in the editor, what functions should I be using to set that rotation?

