Util_Editor_显示RectTransform的世界坐标和相对坐标

下面脚本解决UGUI编辑时看不到世界坐标和相对坐标的问题

[CustomEditor(typeof(RectTransform))]
public class MyRectTransformEditor : Editor
{
    private Editor editor;
    Transform tagetTranform;
    private void OnEnable()
    {
        editor = Editor.CreateEditor(target, Assembly.GetAssembly(typeof(Editor)).GetType("UnityEditor.RectTransformEditor", true));
        tagetTranform = target as RectTransform;

    }
    public override void OnInspectorGUI()
    {
        editor.OnInspectorGUI();
        tagetTranform.position = EditorGUILayout.Vector3Field("世界坐标:", tagetTranform.position);
        tagetTranform.localPosition = EditorGUILayout.Vector3Field("相对坐标:", tagetTranform.localPosition);
    }
}

猜你喜欢

转载自www.cnblogs.com/PandaHome/p/10934820.html
今日推荐