Get inspector rotation values?

Hello, i need to get the exact rotation vector3 value that the inspector shows, i tried using TransformUtils, but i can’t use it because it’s using UnityEditor and i cant’t use that in builds.

I am making a save/load system, the load system works, i use eulerAngles

//load system, it works
Quaternion rot = Quaternion.Euler(eulerAngles.x, eulerAngles.y, eulerAngles.z);

Save system

    //save system, but it does not let me build because i use TransformUtils, how can i get the same result?


Sorry for my english.

but i can’t use it because it’s using
UnityEditor and i cant’t use that in

Well, just use localEulerAngles in the save method as well as when loading. At runtime Unity exclusively uses Quaternions to represent rotations. Unity only keeps the euler angles seperate in the editor to make editing easier. However whenever you actually change the rotation at runtime the euler angles are just calculated backwards from the Quaternion so all angles are always in the range of -180 and 180.

As you probably know, euler angles have infinite combinations to represent the exact same rotation. It’s not just adding 360° to a single rotation axis. For example the rotation (0 0 0) is the same as (180 180 180). Likewise a rotation like (90 0 0) is the same as (90 20 20) or (90 72 72). So you should not focus too much on the exact values.

The inspector usually shows the local euler angles, so they are relative to the parent object. If the object does not have a parent the local euler angles are the same as the (global) eulerAngles.