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.Parse(tempVector3[0]), float.Parse(tempVector3[1]), float.Parse(tempVector3[2]));
return vector3;
}
獲取原生旋轉值 Inspector
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.