获取Unity⾯板中的旋转值
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection; //反编译
/// <summary>
通分是什么意思/// 获取Unity⾯板中的物体的旋转值
卧龙山/// </summary>
public class GetInspectorRotationValue : MonoBehaviour {
public static GetInspectorRotationValue Instance;
private void Awake()
{
Instance = this; //单例模式
不二兔子图片}
public Vector3 GetInspectorRotationValueMethod(Transform transform)
{
// 获取原⽣值传染病报告制度
System.Type transformType = transform.GetType();
PropertyInfo m_propertyInfo_rotationOrder = transformType.GetProperty("rotationOrder", BindingFlags.Instance | BindingFlags.NonPublic);
object m_OldRotationOrder = m_propertyInfo_rotationOrder.GetValue(transform, null);
MethodInfo m_methodInfo_GetLocalEulerAngles = transformType.GetMethod("GetLocalEulerAngles", BindingFlags.Instance | BindingFlags.NonPublic);
束缚的读音 object value = m_methodInfo_GetLocalEulerAngles.Invoke(transform, new object[] { m_OldRotationOrder });
//Debug.Log("反射调⽤GetLocalEulerAngles⽅法获得的值:" + value.ToString());
string temp = value.ToString();
//将字符串第⼀个和最后⼀个去掉
temp = temp.Remove(0, 1);
龟兔赛跑原文temp = temp.Remove(temp.Length - 1, 1);
//⽤‘,’号分割
string[] tempVector3;
tempVector3 = temp.Split(',');
三人间
//将分割好的数据传给Vector3
女朋友睡前故事大全
Vector3 vector3 = new Vector3(float.Par(tempVector3[0]), float.Par(tempVector3[1]), float.Par(tempVector3[2]));
return vector3;
}
}