get the rotation like in inspector unity code example
Example 1: get objects z rotation in degrees unity
gameObject.transform.rotation.eulerAngles.z
Example 2: unity get quaternion z
Quaternion.eurlerAngles.z
gameObject.transform.rotation.eulerAngles.z
Quaternion.eurlerAngles.z