static InspectorUtility()
        {
            //we can use 'OnBeginToolboxEditor' and 'OnCloseToolboxEditor' to cache
            //processed Editors and determine the real context of the serialization
            ToolboxEditor.OnBeginToolboxEditor += (editor) =>
            {
                CurrentTargetObjects = editor.targets;
            };
            ToolboxEditor.OnCloseToolboxEditor += (editor) =>
            {
                CurrentTargetObjects = null;
            };

            //we can use each new Editor to check if 'OnEditorReload' should be called
            ToolboxEditor.OnBeginToolboxEditor += (editor) =>
            {
                if (lastCachedEditor == null)
                {
                    OnEditorReload?.Invoke();
                }

                //this Editor will be destroyed every time when object is deselected
                lastCachedEditor = editor;
            };
        }
Example #2
0
        static InspectorUtility()
        {
            //we can use 'OnBeginToolboxEditor' and 'OnCloseToolboxEditor' to cache
            //processed Editors and determine the real context of the serialization
            ToolboxEditor.OnBeginToolboxEditor += (editor) =>
            {
                CurrentTargetObjects = editor.targets;
            };
            ToolboxEditor.OnCloseToolboxEditor += (editor) =>
            {
                CurrentTargetObjects = null;
            };

            //we should determine whenever the last created Editor is destroyed so
            //using the 'Selection' class is more like a workaround than a solution
            //Selection.selectionChanged += () => OnEditorReload?.Invoke();

            //we can use new Editors to check if 'OnEditorReload' should be called
            ToolboxEditor.OnBeginToolboxEditor += (editor) =>
            {
                if (lastCachedEditor == null)
                {
                    OnEditorReload?.Invoke();
                }

                //cached Editor will be destroyed every time when object is deselected
                lastCachedEditor = editor;
            };
        }
Example #3
0
 private static void CheckReloads(Editor editor)
 {
     //NOTE: it means that last Editor was null or disposed, anyway we probably want to reload drawers-related cache
     if (lastCachedEditor == null || lastCachedEditorId != lastCachedEditor.GetInstanceID())
     {
         lastCachedEditor   = editor;
         lastCachedEditorId = editor.GetInstanceID();
         OnEditorReload?.Invoke();
     }
 }