Model euler angles in code not the same as shown in editor

Hello. I have a model of a gun used in my simulation. This gun is on a turret that pans left and right, and the gun angles up and down around its X axis. I move the gun with Quaternion.Slerp(), which works fine. After it moves, I can pause the simulation, select the gun in the editor, and take note of its euler angles as shown in the editor. They look perfect (i.e. y and z are zero, X is whatever angle I wanted). Now back in the code, I print out the X Y and Z euler angles, and they’re all weird! X is some unexpected value, and Y and Z are non-zero (like 180, or 270). What’s going on? How can I access the X value that the unity editor is showing?

I assume the quaternions are doing stuff to avoid gimbal lock. I just want the X value that Unity shows.

Are you accessing the Euler angles using Transform.localEulerAngles? Or are using some other method?