Ejemplo n.º 1
0
        protected void RegisterSelectedPane(bool sendEvents)
        {
            if (!m_ActualView)
            {
                return;
            }

            m_ActualView.m_Parent = this;

            visualTree.Add(EditorModes.GetRootElement(m_ActualView));
            panel.getViewDataDictionary  = m_ActualView.GetViewDataDictionary;
            panel.savePersistentViewData = m_ActualView.SavePersistentViewData;
            panel.name = m_ActualView.GetType().Name;

            if (GetPaneMethod("Update") != null)
            {
                EditorApplication.update += SendUpdate;
            }

            EditorApplication.update += SendUpdateToOverride;

            if (GetPaneMethod("ModifierKeysChanged") != null)
            {
                EditorApplication.modifierKeysChanged += SendModKeysChanged;
            }

            EditorApplication.update += SendModKeysChangedToOverride;

            m_ActualView.MakeParentsSettingsMatchMe();

            if (m_ActualView.m_FadeoutTime != 0)
            {
                EditorApplication.update += m_ActualView.CheckForWindowRepaint;
            }

            if (sendEvents)
            {
                try
                {
                    Invoke("OnBecameVisible");
                    EditorModes.OnBecameVisible(m_ActualView);
                    Invoke("OnFocus");
                    EditorModes.OnFocus(m_ActualView);
                }
                catch (TargetInvocationException ex)
                {
                    // We need to catch these so the window initialization doesn't get screwed
                    if (ex.InnerException != null)
                    {
                        Debug.LogError(ex.InnerException.GetType().Name + ":" + ex.InnerException.Message);
                    }
                }
            }

            UpdateViewMargins(m_ActualView);
        }
Ejemplo n.º 2
0
        protected void DeregisterSelectedPane(bool clearActualView, bool sendEvents)
        {
            if (!m_ActualView)
            {
                return;
            }

            var root = EditorModes.GetRootElement(m_ActualView);

            if (root.shadow.parent == visualTree)
            {
                visualTree.Remove(root);
                panel.getViewDataDictionary  = null;
                panel.savePersistentViewData = null;
            }

            if (GetPaneMethod("Update") != null)
            {
                EditorApplication.update -= SendUpdate;
            }

            EditorApplication.update -= SendUpdateToOverride;

            if (GetPaneMethod("ModifierKeysChanged") != null)
            {
                EditorApplication.modifierKeysChanged -= SendModKeysChanged;
            }

            EditorApplication.update -= SendModKeysChangedToOverride;

            if (m_ActualView.m_FadeoutTime != 0)
            {
                EditorApplication.update -= m_ActualView.CheckForWindowRepaint;
            }

            if (clearActualView)
            {
                EditorWindow oldActualView = m_ActualView;
                m_ActualView = null;
                if (sendEvents)
                {
                    Invoke("OnLostFocus", oldActualView);
                    EditorModes.OnLostFocus(m_ActualView);
                    Invoke("OnBecameInvisible", oldActualView);
                    EditorModes.OnBecameInvisible(oldActualView);
                }
            }
        }
Ejemplo n.º 3
0
        protected override void UpdateViewMargins(EditorWindow view)
        {
            base.UpdateViewMargins(view);

            if (view == null)
            {
                return;
            }

            RectOffset margins = GetBorderSize();

            IStyle style = EditorModes.GetRootElement(view).style;

            style.positionTop    = margins.top;
            style.positionBottom = margins.bottom;
            style.positionLeft   = margins.left;
            style.positionRight  = margins.right;
            style.positionType   = PositionType.Absolute;
        }
Ejemplo n.º 4
0
        public bool TrySelectWindow(EditorWindow searchedWindow)
        {
            var root = EditorModes.GetRootElement(searchedWindow);

            if (root == null)
            {
                return(false);
            }

            IPanel searchedPanel = root.panel;

            for (int i = 0; i < m_Panels.Count; i++)
            {
                var p = m_Panels[i];
                if (p.Panel == searchedPanel)
                {
                    m_Selected = i + 1;
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
 internal static VisualElement GetRootVisualContainerForCurrentMode(this EditorWindow window)
 {
     return(EditorModes.GetRootElement(window));
 }