public void Rebuild(SmartInspector inspector)
        {
            this.Query <InspectorTab>().ForEach(x => x.RemoveFromHierarchy());


            foreach (var editor in inspector.editors.Values)
            {
                if (editor.element.HasClass("game-object"))
                {
                    continue;
                }

                var target = editor.editor.target;

                if (!target)
                {
                    continue;
                }

                var tab = new InspectorTab(editor);

                if (string.IsNullOrEmpty(tab.name))
                {
                    continue;
                }

                tabsList.Add(tab);

                tab.RegisterCallback <ChangeEvent <bool> >(_ => UpdateEditorsVisibility());
            }

            UpdateEditorsVisibility();
        }
        static SmartInspector InitInspector(EditorWindow window)
        {
            var inspector = new SmartInspector(window);

            SmartInspector.Injected.AddOrAssign(window, inspector);

            inspector.OnEnable();
            return(inspector);
        }
Пример #3
0
        string GetTitle()
        {
            var title = target.name;

            if (target is Component component)
            {
                title = SmartInspector.GetInspectorTitle(component);
            }

            return(title);
        }
Пример #4
0
        /// <see cref="PropertyEditorPatch.RebuildContentsContainers_"/>
        internal void OnRebuildContent(RebuildStage stage)
        {
            RebuildingInspector = this;
            FirstInitOnInspectorIfNeeded();

            if (root == null)
            {
                return;
            }
            if (!prefs.enabled)
            {
                OnUnpatch();
            }

            DisplayOptionalParts();
            OnContentViewportLayout(null);

            //Debug.Log(stage);

            if (stage == RebuildStage.BeforeEditorElements)
            {
                editors.Clear();
                RemoveUserElements();
            }

            if (stage == RebuildStage.BeforeRepaint)
            {
                RemoveDetachedEditors();
                RebuildToolbar();
            }

            if (stage == RebuildStage.AfterRepaint)
            {
                // TODO: Fix one-frame issue when dragged element keeps expanded layout of element that was last there
            }
        }
Пример #5
0
        internal static EditorElement CreateEditorElement(VisualElement element, IMGUIContainer header, IMGUIContainer footer, SmartInspector smartInspector)
        {
            var editor      = EditorElementRef.GetEditor(element);
            var editorIndex = EditorElementRef.GetEditorIndex(element);
            var inspector   = EditorElementRef.GetInspectorElement(element);

            var window  = smartInspector.propertyEditor;
            var tracker = smartInspector.tracker;


            var data = new EditorElement(element)
            {
                header    = header,
                inspector = inspector,
                footer    = footer,

                index         = editorIndex,
                expandedState = -1,

                editor  = editor,
                window  = window,
                tracker = tracker,

                smartInspector = smartInspector,
            };

            return(data);
        }