예제 #1
0
        public void Reinit(int editorIndex)
        {
            if (m_Header == null)
            {
                m_EditorIndex = editorIndex;
                Clear();
                Init();
                return;
            }

            PopulateCache();
            Object editorTarget = editor.targets[0];
            string editorTitle  = ObjectNames.GetInspectorTitle(editorTarget);

            // If the target change we need to invalidate IMGUI container cached measurements
            // See https://fogbugz.unity3d.com/f/cases/1279830/
            if (m_EditorTarget != editorTarget)
            {
                m_Header.MarkDirtyLayout();
                m_Footer.MarkDirtyLayout();
            }

            m_EditorTarget = editorTarget;
            m_EditorIndex  = editorIndex;

            m_Header.onGUIHandler = HeaderOnGUI;
            m_Footer.onGUIHandler = FooterOnGUI;

            name          = editorTitle;
            m_Header.name = editorTitle + "Header";
            m_Footer.name = editorTitle + "Footer";

            if (m_InspectorElement != null)
            {
                m_InspectorElement.AssignExistingEditor(editor);
                m_InspectorElement.name = editorTitle + "Inspector";

                // InspectorElement should be enabled only if the Editor is open for edit.
                m_InspectorElement.SetEnabled(editor.IsOpenForEdit());
            }

            UpdateInspectorVisibility();
        }