Quaternion.Euler

将欧拉角转换为四元数

定义

public static Quaternion Euler (float x, float y, float z);
参数名类型必要说明
xfloatX 轴旋转度数
yfloatY 轴旋转度数
zfloatZ 轴旋转度数
public static Quaternion Euler (Vector euler);
参数名类型必要说明
eulerVector3表示 X、Y、Z 三轴旋转度数的向量

示例

using UnityEngine;

public class Example : MonoBehaviour
{
    private void Start()
    {
        var rotationX = 0;
        var rotationY = 30;
        var rotationZ = 0;
        var rotationVector = new Vector3(rotationX, rotationY, rotationZ);

        var rotation = Quaternion.Euler(rotationX, rotationY, rotationZ);
        var rotation = Quaternion.Euler(rotationVector);
    }
}