Transform.localEulerAngles

Switch to Manual
public Vector3 localEulerAngles ;

Description

以欧拉角表示的相对于父变换旋转的旋转(以度为单位)。

x、y 和 z 角表示一个围绕 Z 轴旋转 z 度、围绕 X 轴旋转 x 度、围绕 Y 轴旋转 y 度(按此顺序)的旋转。

Only use this variable to read and set the angles to absolute values. Don't increment them, as it will fail when the angle exceeds 360 degrees. Use Transform.Rotate instead.

using UnityEngine;

public class Example : MonoBehaviour { void Start() { // Print the rotation around the parent's X Axis print(transform.localEulerAngles.x); // Print the rotation around the parent's Y Axis print(transform.localEulerAngles.y); // Print the rotation around the parent's Z Axis print(transform.localEulerAngles.z); } }

Unity automatically converts the angles to and from the rotation stored in Transform.localRotation.