1

图片描述

如果不知道图片在表达些什么,请仔细看Inspector右上角的小锁头。。。。

    [MenuItem("Custom/InspectorFlipLocked &L")]
    static void MenuItem_InspectorFlipLocked()
    {
        System.Type typeInspector = typeof(EditorWindow).Assembly.GetType("UnityEditor.InspectorWindow");
        EditorWindow w = EditorWindow.focusedWindow;
        if(!typeInspector.IsInstanceOfType(w))
        {
            w = null;
            Object[] objs = Resources.FindObjectsOfTypeAll(typeInspector);
            if(objs.Length > 0) w = objs[0] as EditorWindow;
        }
        if(w!=null)
        {
            ActiveEditorTracker tracker = typeInspector.InvokeMember("GetTracker", BindingFlags.InvokeMethod, null, w, null) as ActiveEditorTracker;
            tracker.isLocked = !tracker.isLocked;
            Debug.Log("Inspector at " + w.position + " is " + (tracker.isLocked?"LOCKED":"UNLOCKED"));
            w.Repaint();
        }
    }

迷途吧
145 声望25 粉丝

看见好文章就翻译一下,发现一些细节就分享一下,也许没什么技术,只希望能被需要的人搜到。


引用和评论

0 条评论