Hi, I’m not sure in which category to put this question so if it’s not in the right place, tell me and I’ll move it.
In my game I need to access the Euler angles of an object as they are displayed in the editor.
Accessing transform.eulerAngles works most of the times, but I have an object that has (90, 0, 90) as Euler angles displayed in the inspector. When I use transform.eulerAngles on this object, I get (90, 270, 0). That is a problem since I’m using that value in a shader, and there is a big difference between the two vectors.
How can I turn the value I get from transform.eulerAngles into the value I see in the inspector ? Without using UnityEditor functions since I need it to work in the build.
My testing script :
[SerializeField] private Vector3 euler;
[Button]
public void Test()
{
euler = transform.eulerAngles;
Debug.Log($"Euler : {transform.eulerAngles}");
}
The vector used in the shader :
Result with Euler angles of (90, 270, 0) in the shader :
Expected result with Euler angles of (90, 0, 90) in the shader :