AddTab() public method

public AddTab ( EditorWindow pane ) : void
pane EditorWindow
return void
Esempio n. 1
0
        internal void Reload(object userData)
        {
            EditorWindow window = userData as EditorWindow;

            if (window == null)
            {
                return;
            }

            // Get some info on the existing window.
            Type windowType = window.GetType();

            // Save what we can of the window.
            string windowJson = EditorJsonUtility.ToJson(window);

            DockArea dockArea = window.m_Parent as DockArea;

            if (dockArea != null)
            {
                int windowIndex = dockArea.m_Panes.IndexOf(window);

                // Destroy window.
                dockArea.RemoveTab(window, false); // Don't kill dock if empty.
                DestroyImmediate(window, true);

                // Create window.
                window = EditorWindow.CreateInstance(windowType) as EditorWindow;
                dockArea.AddTab(windowIndex, window);
            }
            else
            {
                // Close the existing window.
                window.Close();

                // Recreate window.
                window = EditorWindow.CreateInstance(windowType) as EditorWindow;
                if (window != null)
                {
                    window.Show();
                }
            }

            // Restore what we can of the window.
            EditorJsonUtility.FromJsonOverwrite(windowJson, window);
        }
Esempio n. 2
0
        internal static void CreateNewWindowForEditorWindow(EditorWindow window, Vector2 screenPosition, bool loadPosition, bool showImmediately)
        {
            ContainerWindow containerWindow = ScriptableObject.CreateInstance <ContainerWindow>();
            SplitView       splitView       = ScriptableObject.CreateInstance <SplitView>();

            containerWindow.rootView = splitView;
            DockArea dockArea = ScriptableObject.CreateInstance <DockArea>();

            splitView.AddChild(dockArea);
            dockArea.AddTab(window);
            Rect position = window.m_Parent.borderSize.Add(new Rect(screenPosition.x, screenPosition.y, window.position.width, window.position.height));

            containerWindow.position = position;
            splitView.position       = new Rect(0f, 0f, position.width, position.height);
            window.MakeParentsSettingsMatchMe();
            containerWindow.Show(ShowMode.NormalWindow, loadPosition, showImmediately);
            containerWindow.OnResize();
        }
Esempio n. 3
0
        internal static void CreateNewWindowForEditorWindow(EditorWindow window, Vector2 screenPosition, bool loadPosition, bool showImmediately)
        {
            ContainerWindow window2 = ScriptableObject.CreateInstance <ContainerWindow>();
            SplitView       view    = ScriptableObject.CreateInstance <SplitView>();

            window2.rootView = view;
            DockArea child = ScriptableObject.CreateInstance <DockArea>();

            view.AddChild(child);
            child.AddTab(window);
            Rect rect = window.m_Parent.borderSize.Add(new Rect(screenPosition.x, screenPosition.y, window.position.width, window.position.height));

            window2.position = rect;
            view.position    = new Rect(0f, 0f, rect.width, rect.height);
            window.MakeParentsSettingsMatchMe();
            window2.Show(ShowMode.NormalWindow, loadPosition, showImmediately);
            window2.OnResize();
        }
Esempio n. 4
0
        internal static void CreateNewWindowForEditorWindow(EditorWindow window, Vector2 screenPosition, bool loadPosition, bool showImmediately)
        {
            ContainerWindow instance1 = ScriptableObject.CreateInstance <ContainerWindow>();
            SplitView       instance2 = ScriptableObject.CreateInstance <SplitView>();

            instance1.mainView = (View)instance2;
            DockArea instance3 = ScriptableObject.CreateInstance <DockArea>();

            instance2.AddChild((View)instance3);
            instance3.AddTab(window);
            Rect rect = window.m_Parent.borderSize.Add(new Rect(screenPosition.x, screenPosition.y, window.position.width, window.position.height));

            instance1.position = rect;
            instance2.position = new Rect(0.0f, 0.0f, rect.width, rect.height);
            window.MakeParentsSettingsMatchMe();
            instance1.Show(ShowMode.NormalWindow, loadPosition, showImmediately);
            instance1.OnResize();
        }
Esempio n. 5
0
        // Internal stuff:
        // Helper to show this EditorWindow
        internal static void CreateNewWindowForEditorWindow(EditorWindow window, bool loadPosition, bool showImmediately, bool setFocus = true)
        {
            ContainerWindow cw = ScriptableObject.CreateInstance <ContainerWindow>();
            SplitView       sw = ScriptableObject.CreateInstance <SplitView>();

            cw.rootView = sw;
            DockArea da = ScriptableObject.CreateInstance <DockArea>();

            da.AddTab(window, setFocus);
            sw.AddChild(da);
            Rect r = window.m_Parent.borderSize.Add(window.position);

            cw.position = r;
            sw.position = new Rect(0, 0, r.width, r.height);
            window.MakeParentsSettingsMatchMe();
            cw.Show(ShowMode.NormalWindow, loadPosition, showImmediately, setFocus: true);
            //Need this, as show my change the size of the window, due to screen constraints
            cw.OnResize();
        }
Esempio n. 6
0
        public static T GetWindow <T>(string title, bool focus, params System.Type[] desiredDockNextTo) where T : EditorWindow
        {
            T[] objectsOfTypeAll = Resources.FindObjectsOfTypeAll(typeof(T)) as T[];
            T   obj = objectsOfTypeAll.Length <= 0 ? (T)null : objectsOfTypeAll[0];

            if ((UnityEngine.Object)obj != (UnityEngine.Object)null)
            {
                if (focus)
                {
                    obj.Focus();
                }
                return(obj);
            }
            T instance = ScriptableObject.CreateInstance <T>();

            if (title != null)
            {
                instance.titleContent = new GUIContent(title);
            }
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            EditorWindow.\u003CGetWindow\u003Ec__AnonStorey12 <T> windowCAnonStorey12 = new EditorWindow.\u003CGetWindow\u003Ec__AnonStorey12 <T>();
            foreach (System.Type type in desiredDockNextTo)
            {
                // ISSUE: reference to a compiler-generated field
                windowCAnonStorey12.desired = type;
                foreach (ContainerWindow window in ContainerWindow.windows)
                {
                    foreach (View allChild in window.mainView.allChildren)
                    {
                        DockArea dockArea = allChild as DockArea;
                        // ISSUE: reference to a compiler-generated method
                        if (!((UnityEngine.Object)dockArea == (UnityEngine.Object)null) && dockArea.m_Panes.Any <EditorWindow>(new Func <EditorWindow, bool>(windowCAnonStorey12.\u003C\u003Em__13)))
                        {
                            dockArea.AddTab((EditorWindow)instance);
                            return(instance);
                        }
                    }
                }
            }
            instance.Show();
            return(instance);
        }
        public static void Unmaximize(EditorWindow win)
        {
            HostView maximizedHostView = win.m_Parent;

            if (maximizedHostView == null)
            {
                Debug.LogError("Host view was not found");
                RevertFactorySettings();
                return;
            }

            UnityObject[] newWindows = InternalEditorUtility.LoadSerializedFileAndForget(Path.Combine(layoutsProjectPath, kMaximizeRestoreFile));

            if (newWindows.Length < 2)
            {
                Debug.Log("Maximized serialized file backup not found");
                RevertFactorySettings();
                return;
            }

            SplitView    oldRoot   = newWindows[0] as SplitView;
            EditorWindow oldWindow = newWindows[1] as EditorWindow;

            if (oldRoot == null)
            {
                Debug.Log("Maximization failed because the root split view was not found");
                RevertFactorySettings();
                return;
            }

            ContainerWindow parentWindow = win.m_Parent.window;

            if (parentWindow == null)
            {
                Debug.Log("Maximization failed because the root split view has no container window");
                RevertFactorySettings();
                return;
            }

            try
            {
                ContainerWindow.SetFreezeDisplay(true);

                // Put the loaded SplitView where the MaximizedHostView was
                if (maximizedHostView.parent)
                {
                    int  i      = maximizedHostView.parent.IndexOfChild(maximizedHostView);
                    Rect r      = maximizedHostView.position;
                    View parent = maximizedHostView.parent;
                    parent.RemoveChild(i);
                    parent.AddChild(oldRoot, i);
                    oldRoot.position = r;

                    // Move the Editor Window to the right spot in the
                    DockArea newDockArea = oldWindow.m_Parent as DockArea;

                    int oldDockAreaIndex = newDockArea.m_Panes.IndexOf(oldWindow);

                    maximizedHostView.actualView = null;
                    win.m_Parent = null;
                    newDockArea.AddTab(oldDockAreaIndex, win);
                    newDockArea.RemoveTab(oldWindow);
                    UnityObject.DestroyImmediate(oldWindow);

                    foreach (UnityObject o in newWindows)
                    {
                        EditorWindow curWin = o as EditorWindow;
                        if (curWin != null)
                        {
                            curWin.MakeParentsSettingsMatchMe();
                        }
                    }

                    parent.Initialize(parent.window);
                    //If parent window had to be resized, call this to make sure new size gets propagated
                    parent.position = parent.position;
                    oldRoot.Reflow();
                }
                else
                {
                    throw new System.Exception();
                }

                // Kill the maximizedMainView
                UnityObject.DestroyImmediate(maximizedHostView);

                win.Focus();

                parentWindow.DisplayAllViews();
                win.m_Parent.MakeVistaDWMHappyDance();
            }
            catch (System.Exception ex)
            {
                Debug.Log("Maximization failed: " + ex);
                RevertFactorySettings();
            }

            try
            {
                // Weird bug on AMD graphic cards under OSX Lion: Sometimes when unmaximizing we get stray white rectangles.
                // work around that by issueing an extra repaint (case 438764)
                if (Application.platform == RuntimePlatform.OSXEditor && SystemInfo.operatingSystem.Contains("10.7") && SystemInfo.graphicsDeviceVendor.Contains("ATI"))
                {
                    foreach (GUIView v in Resources.FindObjectsOfTypeAll(typeof(GUIView)))
                    {
                        v.Repaint();
                    }
                }
            }
            finally
            {
                ContainerWindow.SetFreezeDisplay(false);
            }
        }
        static internal EditorWindow ShowAppropriateViewOnEnterExitPlaymode(bool entering)
        {
            // Prevent trying to go into the same state as we're already in, as it wil break things
            if (WindowFocusState.instance.m_CurrentlyInPlayMode == entering)
            {
                return(null);
            }

            WindowFocusState.instance.m_CurrentlyInPlayMode = entering;

            EditorWindow window = null;

            EditorWindow maximized = GetMaximizedWindow();

            if (entering)
            {
                WindowFocusState.instance.m_WasMaximizedBeforePlay = (maximized != null);
                // If a view is already maximized before entering play mode,
                // just keep that maximized view, no matter if it's the game view or some other.
                // Trust that user has a good reason (desire by Ethan etc.)
                if (maximized != null)
                {
                    return(maximized);
                }
            }
            else
            {
                // If a view was already maximized before entering play mode,
                // then it was kept when switching to play mode, and can simply still be kept when exiting
                if (WindowFocusState.instance.m_WasMaximizedBeforePlay)
                {
                    return(maximized);
                }
            }

            // Unmaximize if maximized
            if (maximized)
            {
                Unmaximize(maximized);
            }

            // Try finding and focusing appropriate window/tab
            window = TryFocusAppropriateWindow(entering);
            if (window)
            {
                return(window);
            }

            // If we are entering Play more and no Game View was found, create one
            if (entering)
            {
                // Try to create and focus a Game View tab docked together with the Scene View tab
                EditorWindow sceneView = FindEditorWindowOfType(typeof(SceneView));
                GameView     gameView;
                if (sceneView && sceneView.m_Parent is DockArea)
                {
                    DockArea dock = sceneView.m_Parent as DockArea;
                    if (dock)
                    {
                        WindowFocusState.instance.m_LastWindowTypeInSameDock = sceneView.GetType().ToString();
                        gameView = ScriptableObject.CreateInstance <GameView>();
                        dock.AddTab(gameView);
                        return(gameView);
                    }
                }

                // If no Scene View was found at all, just create a floating Game View
                gameView = ScriptableObject.CreateInstance <GameView>();
                gameView.Show(true);
                gameView.Focus();

                return(gameView);
            }

            return(window);
        }
Esempio n. 9
0
        public bool PerformDrop(EditorWindow w, DropInfo di, Vector2 screenPos)
        {
            int      userData  = (int)di.userData;
            DockArea instance1 = ScriptableObject.CreateInstance <DockArea>();
            Rect     rect      = di.rect;

            if (userData == -1 || userData == -2 || userData == -3)
            {
                bool flag1 = userData == -2;
                bool flag2 = userData == -1;
                this.splitState = (SplitterState)null;
                if (this.vertical == flag2 || this.children.Length < 2)
                {
                    this.vertical = flag2;
                    rect.x       -= this.screenPosition.x;
                    rect.y       -= this.screenPosition.y;
                    this.MakeRoomForRect(rect);
                    this.AddChild((View)instance1, !flag1 ? this.children.Length : 0);
                    instance1.position = rect;
                }
                else
                {
                    SplitView instance2 = ScriptableObject.CreateInstance <SplitView>();
                    Rect      position  = this.position;
                    instance2.vertical = flag2;
                    instance2.position = new Rect(position.x, position.y, position.width, position.height);
                    if ((Object)this.window.mainView == (Object)this)
                    {
                        this.window.mainView = (View)instance2;
                    }
                    else
                    {
                        this.parent.AddChild((View)instance2, this.parent.IndexOfChild((View)this));
                    }
                    instance2.AddChild((View)this);
                    this.position = new Rect(0.0f, 0.0f, position.width, position.height);
                    Rect r = rect;
                    r.x -= this.screenPosition.x;
                    r.y -= this.screenPosition.y;
                    instance2.MakeRoomForRect(r);
                    instance1.position = r;
                    instance2.AddChild((View)instance1, !flag1 ? 1 : 0);
                }
            }
            else if (userData < 1000)
            {
                Rect r = rect;
                r.x -= this.screenPosition.x;
                r.y -= this.screenPosition.y;
                this.MakeRoomForRect(r);
                this.AddChild((View)instance1, userData);
                instance1.position = r;
            }
            else
            {
                int idx = userData % 1000;
                if (this.children.Length != 1)
                {
                    SplitView instance2 = ScriptableObject.CreateInstance <SplitView>();
                    instance2.vertical = !this.vertical;
                    Rect position = this.children[idx].position;
                    instance2.AddChild(this.children[idx]);
                    this.AddChild((View)instance2, idx);
                    instance2.position = position;
                    // ISSUE: explicit reference operation
                    // ISSUE: variable of a reference type
                    Rect& local = @position;
                    float num1  = 0.0f;
                    position.y = num1;
                    double num2 = (double)num1;
                    // ISSUE: explicit reference operation
                    (^ local).x = (float)num2;
                    instance2.children[0].position = position;
                    Rect r = rect;
                    r.x -= instance2.screenPosition.x;
                    r.y -= instance2.screenPosition.y;
                    instance2.MakeRoomForRect(r);
                    instance2.AddChild((View)instance1, userData >= 2000 ? 1 : 0);
                    instance1.position = r;
                }
                else
                {
                    this.vertical = !this.vertical;
                    Rect r = rect;
                    r.x -= this.screenPosition.x;
                    r.y -= this.screenPosition.y;
                    this.MakeRoomForRect(r);
                    this.AddChild((View)instance1, userData != 1000 ? 1 : 0);
                    instance1.position = r;
                }
            }
            DockArea.s_OriginalDragSource.RemoveTab(w);
            w.m_Parent = (HostView)instance1;
            instance1.AddTab(w);
            this.Reflow();
            SplitView.RecalcMinMaxAndReflowAll(this);
            instance1.MakeVistaDWMHappyDance();
            return(true);
        }
Esempio n. 10
0
        public bool PerformDrop(EditorWindow dropWindow, DropInfo dropInfo, Vector2 screenPos)
        {
            ExtraDropInfo userData   = dropInfo.userData as ExtraDropInfo;
            bool          rootWindow = userData.rootWindow;
            ViewEdge      edge       = userData.edge;
            int           index      = userData.index;
            Rect          r          = dropInfo.rect;
            bool          flag2      = (edge & ViewEdge.Before) != ViewEdge.None;
            bool          flag3      = (edge & ViewEdge.FitsVertical) != ViewEdge.None;
            SplitView     view       = null;

            if ((this.vertical == flag3) || (base.children.Length < 2))
            {
                if (!flag2)
                {
                    if (rootWindow)
                    {
                        index = base.children.Length;
                    }
                    else
                    {
                        index++;
                    }
                }
                view = this;
            }
            else if (rootWindow)
            {
                SplitView view2 = ScriptableObject.CreateInstance <SplitView>();
                view2.position = base.position;
                if (base.window.rootView == this)
                {
                    base.window.rootView = view2;
                }
                else
                {
                    base.parent.AddChild(view2, base.parent.IndexOfChild(this));
                }
                view2.AddChild(this);
                base.position = new Rect(Vector2.zero, base.position.size);
                index         = !flag2 ? 1 : 0;
                view          = view2;
            }
            else
            {
                SplitView view3 = ScriptableObject.CreateInstance <SplitView>();
                view3.AddChild(base.children[index]);
                this.AddChild(view3, index);
                view3.position             = view3.children[0].position;
                view3.children[0].position = new Rect(Vector2.zero, view3.position.size);
                index = !flag2 ? 1 : 0;
                view  = view3;
            }
            r.position -= base.screenPosition.position;
            DockArea child = ScriptableObject.CreateInstance <DockArea>();

            view.vertical = flag3;
            view.MakeRoomForRect(r);
            view.AddChild(child, index);
            child.position = r;
            DockArea.s_OriginalDragSource.RemoveTab(dropWindow);
            dropWindow.m_Parent = child;
            child.AddTab(dropWindow);
            this.Reflow();
            RecalcMinMaxAndReflowAll(this);
            child.MakeVistaDWMHappyDance();
            return(true);
        }
Esempio n. 11
0
        public bool PerformDrop(EditorWindow dropWindow, DropInfo dropInfo, Vector2 screenPos)
        {
            SplitView.ExtraDropInfo extraDropInfo = dropInfo.userData as SplitView.ExtraDropInfo;
            bool rootWindow = extraDropInfo.rootWindow;

            SplitView.ViewEdge edge = extraDropInfo.edge;
            int       num           = extraDropInfo.index;
            Rect      rect          = dropInfo.rect;
            bool      flag          = (edge & SplitView.ViewEdge.TopLeft) != SplitView.ViewEdge.None;
            bool      flag2         = (edge & SplitView.ViewEdge.FitsVertical) != SplitView.ViewEdge.None;
            SplitView splitView;

            if (this.vertical == flag2 || base.children.Length < 2)
            {
                if (!flag)
                {
                    if (rootWindow)
                    {
                        num = base.children.Length;
                    }
                    else
                    {
                        num++;
                    }
                }
                splitView = this;
            }
            else if (rootWindow)
            {
                SplitView splitView2 = ScriptableObject.CreateInstance <SplitView>();
                splitView2.position = base.position;
                if (base.window.rootView == this)
                {
                    base.window.rootView = splitView2;
                }
                else
                {
                    base.parent.AddChild(splitView2, base.parent.IndexOfChild(this));
                }
                splitView2.AddChild(this);
                base.position = new Rect(Vector2.zero, base.position.size);
                num           = ((!flag) ? 1 : 0);
                splitView     = splitView2;
            }
            else
            {
                SplitView splitView3 = ScriptableObject.CreateInstance <SplitView>();
                splitView3.AddChild(base.children[num]);
                this.AddChild(splitView3, num);
                splitView3.position             = splitView3.children[0].position;
                splitView3.children[0].position = new Rect(Vector2.zero, splitView3.position.size);
                num       = ((!flag) ? 1 : 0);
                splitView = splitView3;
            }
            rect.position -= base.screenPosition.position;
            DockArea dockArea = ScriptableObject.CreateInstance <DockArea>();

            splitView.vertical = flag2;
            splitView.MakeRoomForRect(rect);
            splitView.AddChild(dockArea, num);
            dockArea.position = rect;
            DockArea.s_OriginalDragSource.RemoveTab(dropWindow);
            dropWindow.m_Parent = dockArea;
            dockArea.AddTab(dropWindow);
            this.Reflow();
            SplitView.RecalcMinMaxAndReflowAll(this);
            dockArea.MakeVistaDWMHappyDance();
            return(true);
        }
Esempio n. 12
0
        public bool PerformDrop(EditorWindow w, DropInfo di, Vector2 screenPos)
        {
            int      userData = (int)di.userData;
            DockArea child    = ScriptableObject.CreateInstance <DockArea>();
            Rect     r        = di.rect;

            switch (userData)
            {
            case -1:
            case -2:
            case -3:
            {
                bool flag  = userData == -2;
                bool flag2 = userData == -1;
                this.splitState = null;
                if ((this.vertical == flag2) || (base.children.Length < 2))
                {
                    this.vertical = flag2;
                    r.x          -= base.screenPosition.x;
                    r.y          -= base.screenPosition.y;
                    this.MakeRoomForRect(r);
                    this.AddChild(child, !flag ? base.children.Length : 0);
                    child.position = r;
                }
                else
                {
                    SplitView view     = ScriptableObject.CreateInstance <SplitView>();
                    Rect      position = base.position;
                    view.vertical = flag2;
                    view.position = new Rect(position.x, position.y, position.width, position.height);
                    if (base.window.mainView == this)
                    {
                        base.window.mainView = view;
                    }
                    else
                    {
                        base.parent.AddChild(view, base.parent.IndexOfChild(this));
                    }
                    view.AddChild(this);
                    base.position = new Rect(0f, 0f, position.width, position.height);
                    Rect rect3 = r;
                    rect3.x -= base.screenPosition.x;
                    rect3.y -= base.screenPosition.y;
                    view.MakeRoomForRect(rect3);
                    child.position = rect3;
                    view.AddChild(child, !flag ? 1 : 0);
                }
                break;
            }

            default:
                if (userData < 0x3e8)
                {
                    Rect rect4 = r;
                    rect4.x -= base.screenPosition.x;
                    rect4.y -= base.screenPosition.y;
                    this.MakeRoomForRect(rect4);
                    this.AddChild(child, userData);
                    child.position = rect4;
                }
                else
                {
                    int index = userData % 0x3e8;
                    if (base.children.Length != 1)
                    {
                        SplitView view2 = ScriptableObject.CreateInstance <SplitView>();
                        view2.vertical = !this.vertical;
                        Rect rect5 = base.children[index].position;
                        view2.AddChild(base.children[index]);
                        this.AddChild(view2, index);
                        view2.position = rect5;
                        float num3 = 0f;
                        rect5.y = num3;
                        rect5.x = num3;
                        view2.children[0].position = rect5;
                        Rect rect6 = r;
                        rect6.x -= view2.screenPosition.x;
                        rect6.y -= view2.screenPosition.y;
                        view2.MakeRoomForRect(rect6);
                        view2.AddChild(child, (userData >= 0x7d0) ? 1 : 0);
                        child.position = rect6;
                    }
                    else
                    {
                        this.vertical = !this.vertical;
                        Rect rect7 = r;
                        rect7.x -= base.screenPosition.x;
                        rect7.y -= base.screenPosition.y;
                        this.MakeRoomForRect(rect7);
                        this.AddChild(child, (userData != 0x3e8) ? 1 : 0);
                        child.position = rect7;
                    }
                }
                break;
            }
            DockArea.s_OriginalDragSource.RemoveTab(w);
            w.m_Parent = child;
            child.AddTab(w);
            this.Reflow();
            RecalcMinMaxAndReflowAll(this);
            child.MakeVistaDWMHappyDance();
            return(true);
        }
Esempio n. 13
0
        public bool PerformDrop(EditorWindow w, DropInfo di, Vector2 screenPos)
        {
            int      num      = (int)di.userData;
            DockArea dockArea = ScriptableObject.CreateInstance <DockArea>();
            Rect     rect     = di.rect;

            if (num == -1 || num == -2 || num == -3)
            {
                bool flag  = num == -2;
                bool flag2 = num == -1;
                this.splitState = null;
                if (this.vertical == flag2 || base.children.Length < 2)
                {
                    this.vertical = flag2;
                    rect.x       -= base.screenPosition.x;
                    rect.y       -= base.screenPosition.y;
                    this.MakeRoomForRect(rect);
                    this.AddChild(dockArea, (!flag) ? base.children.Length : 0);
                    dockArea.position = rect;
                }
                else
                {
                    SplitView splitView = ScriptableObject.CreateInstance <SplitView>();
                    Rect      position  = base.position;
                    splitView.vertical = flag2;
                    splitView.position = new Rect(position.x, position.y, position.width, position.height);
                    if (base.window.mainView == this)
                    {
                        base.window.mainView = splitView;
                    }
                    else
                    {
                        base.parent.AddChild(splitView, base.parent.IndexOfChild(this));
                    }
                    splitView.AddChild(this);
                    base.position = new Rect(0f, 0f, position.width, position.height);
                    Rect rect2 = rect;
                    rect2.x -= base.screenPosition.x;
                    rect2.y -= base.screenPosition.y;
                    splitView.MakeRoomForRect(rect2);
                    dockArea.position = rect2;
                    splitView.AddChild(dockArea, (!flag) ? 1 : 0);
                }
            }
            else
            {
                if (num < 1000)
                {
                    Rect rect3 = rect;
                    rect3.x -= base.screenPosition.x;
                    rect3.y -= base.screenPosition.y;
                    this.MakeRoomForRect(rect3);
                    this.AddChild(dockArea, num);
                    dockArea.position = rect3;
                }
                else
                {
                    int num2 = num % 1000;
                    if (base.children.Length != 1)
                    {
                        SplitView splitView2 = ScriptableObject.CreateInstance <SplitView>();
                        splitView2.vertical = !this.vertical;
                        Rect position2 = base.children[num2].position;
                        splitView2.AddChild(base.children[num2]);
                        this.AddChild(splitView2, num2);
                        splitView2.position = position2;
                        float num3 = 0f;
                        position2.y = num3;
                        position2.x = num3;
                        splitView2.children[0].position = position2;
                        Rect rect4 = rect;
                        rect4.x -= splitView2.screenPosition.x;
                        rect4.y -= splitView2.screenPosition.y;
                        splitView2.MakeRoomForRect(rect4);
                        splitView2.AddChild(dockArea, (num >= 2000) ? 1 : 0);
                        dockArea.position = rect4;
                    }
                    else
                    {
                        this.vertical = !this.vertical;
                        Rect rect5 = rect;
                        rect5.x -= base.screenPosition.x;
                        rect5.y -= base.screenPosition.y;
                        this.MakeRoomForRect(rect5);
                        this.AddChild(dockArea, (num != 1000) ? 1 : 0);
                        dockArea.position = rect5;
                    }
                }
            }
            DockArea.s_OriginalDragSource.RemoveTab(w);
            w.m_Parent = dockArea;
            dockArea.AddTab(w);
            this.Reflow();
            SplitView.RecalcMinMaxAndReflowAll(this);
            dockArea.MakeVistaDWMHappyDance();
            return(true);
        }
Esempio n. 14
0
 public static void Unmaximize(EditorWindow win)
 {
     HostView parent = win.m_Parent;
     if (parent == null)
     {
         UnityEngine.Debug.LogError("Host view was not found");
         RevertFactorySettings();
     }
     else
     {
         UnityEngine.Object[] objArray = InternalEditorUtility.LoadSerializedFileAndForget(Path.Combine(layoutsProjectPath, "CurrentMaximizeLayout.dwlt"));
         if (objArray.Length < 2)
         {
             UnityEngine.Debug.Log("Maximized serialized file backup not found");
             RevertFactorySettings();
         }
         else
         {
             SplitView child = objArray[0] as SplitView;
             EditorWindow item = objArray[1] as EditorWindow;
             if (child == null)
             {
                 UnityEngine.Debug.Log("Maximization failed because the root split view was not found");
                 RevertFactorySettings();
             }
             else
             {
                 ContainerWindow window = win.m_Parent.window;
                 if (window == null)
                 {
                     UnityEngine.Debug.Log("Maximization failed because the root split view has no container window");
                     RevertFactorySettings();
                 }
                 else
                 {
                     try
                     {
                         ContainerWindow.SetFreezeDisplay(true);
                         if (parent.parent == null)
                         {
                             throw new Exception();
                         }
                         int idx = parent.parent.IndexOfChild(parent);
                         Rect position = parent.position;
                         View view3 = parent.parent;
                         view3.RemoveChild(idx);
                         view3.AddChild(child, idx);
                         child.position = position;
                         DockArea area = item.m_Parent as DockArea;
                         int index = area.m_Panes.IndexOf(item);
                         parent.actualView = null;
                         win.m_Parent = null;
                         area.AddTab(index, win);
                         area.RemoveTab(item);
                         UnityEngine.Object.DestroyImmediate(item);
                         foreach (UnityEngine.Object obj2 in objArray)
                         {
                             EditorWindow window3 = obj2 as EditorWindow;
                             if (window3 != null)
                             {
                                 window3.MakeParentsSettingsMatchMe();
                             }
                         }
                         view3.Initialize(view3.window);
                         view3.position = view3.position;
                         child.Reflow();
                         UnityEngine.Object.DestroyImmediate(parent);
                         win.Focus();
                         window.DisplayAllViews();
                         win.m_Parent.MakeVistaDWMHappyDance();
                     }
                     catch (Exception exception)
                     {
                         UnityEngine.Debug.Log("Maximization failed: " + exception);
                         RevertFactorySettings();
                     }
                     try
                     {
                         if (((Application.platform == RuntimePlatform.OSXEditor) && SystemInfo.operatingSystem.Contains("10.7")) && SystemInfo.graphicsDeviceVendor.Contains("ATI"))
                         {
                             foreach (GUIView view4 in UnityEngine.Resources.FindObjectsOfTypeAll(typeof(GUIView)))
                             {
                                 view4.Repaint();
                             }
                         }
                     }
                     finally
                     {
                         ContainerWindow.SetFreezeDisplay(false);
                     }
                 }
             }
         }
     }
 }
Esempio n. 15
0
        internal static EditorWindow ShowAppropriateViewOnEnterExitPlaymode(bool entering)
        {
            EditorWindow result;

            if (WindowFocusState.instance.m_CurrentlyInPlayMode == entering)
            {
                result = null;
            }
            else
            {
                WindowFocusState.instance.m_CurrentlyInPlayMode = entering;
                EditorWindow maximizedWindow = WindowLayout.GetMaximizedWindow();
                if (entering)
                {
                    WindowFocusState.instance.m_WasMaximizedBeforePlay = (maximizedWindow != null);
                    if (maximizedWindow != null)
                    {
                        result = maximizedWindow;
                        return(result);
                    }
                }
                else if (WindowFocusState.instance.m_WasMaximizedBeforePlay)
                {
                    result = maximizedWindow;
                    return(result);
                }
                if (maximizedWindow)
                {
                    WindowLayout.Unmaximize(maximizedWindow);
                }
                EditorWindow editorWindow = WindowLayout.TryFocusAppropriateWindow(entering);
                if (editorWindow)
                {
                    result = editorWindow;
                }
                else if (entering)
                {
                    EditorWindow editorWindow2 = WindowLayout.FindEditorWindowOfType(typeof(SceneView));
                    GameView     gameView;
                    if (editorWindow2 && editorWindow2.m_Parent is DockArea)
                    {
                        DockArea dockArea = editorWindow2.m_Parent as DockArea;
                        if (dockArea)
                        {
                            WindowFocusState.instance.m_LastWindowTypeInSameDock = editorWindow2.GetType().ToString();
                            gameView = ScriptableObject.CreateInstance <GameView>();
                            dockArea.AddTab(gameView);
                            result = gameView;
                            return(result);
                        }
                    }
                    gameView = ScriptableObject.CreateInstance <GameView>();
                    gameView.Show(true);
                    gameView.Focus();
                    result = gameView;
                }
                else
                {
                    result = editorWindow;
                }
            }
            return(result);
        }
Esempio n. 16
0
        public static void Unmaximize(EditorWindow win)
        {
            HostView parent = win.m_Parent;

            if (parent == null)
            {
                UnityEngine.Debug.LogError("Host view was not found");
                WindowLayout.RevertFactorySettings();
            }
            else
            {
                UnityEngine.Object[] array = InternalEditorUtility.LoadSerializedFileAndForget(Path.Combine(WindowLayout.layoutsProjectPath, "CurrentMaximizeLayout.dwlt"));
                if (array.Length < 2)
                {
                    UnityEngine.Debug.Log("Maximized serialized file backup not found");
                    WindowLayout.RevertFactorySettings();
                }
                else
                {
                    SplitView    splitView    = array[0] as SplitView;
                    EditorWindow editorWindow = array[1] as EditorWindow;
                    if (splitView == null)
                    {
                        UnityEngine.Debug.Log("Maximization failed because the root split view was not found");
                        WindowLayout.RevertFactorySettings();
                    }
                    else
                    {
                        ContainerWindow window = win.m_Parent.window;
                        if (window == null)
                        {
                            UnityEngine.Debug.Log("Maximization failed because the root split view has no container window");
                            WindowLayout.RevertFactorySettings();
                        }
                        else
                        {
                            try
                            {
                                ContainerWindow.SetFreezeDisplay(true);
                                if (!parent.parent)
                                {
                                    throw new Exception();
                                }
                                int  idx      = parent.parent.IndexOfChild(parent);
                                Rect position = parent.position;
                                View parent2  = parent.parent;
                                parent2.RemoveChild(idx);
                                parent2.AddChild(splitView, idx);
                                splitView.position = position;
                                DockArea dockArea = editorWindow.m_Parent as DockArea;
                                int      idx2     = dockArea.m_Panes.IndexOf(editorWindow);
                                parent.actualView = null;
                                win.m_Parent      = null;
                                dockArea.AddTab(idx2, win);
                                dockArea.RemoveTab(editorWindow);
                                UnityEngine.Object.DestroyImmediate(editorWindow);
                                UnityEngine.Object[] array2 = array;
                                for (int i = 0; i < array2.Length; i++)
                                {
                                    UnityEngine.Object @object       = array2[i];
                                    EditorWindow       editorWindow2 = @object as EditorWindow;
                                    if (editorWindow2 != null)
                                    {
                                        editorWindow2.MakeParentsSettingsMatchMe();
                                    }
                                }
                                parent2.Initialize(parent2.window);
                                parent2.position = parent2.position;
                                splitView.Reflow();
                                UnityEngine.Object.DestroyImmediate(parent);
                                win.Focus();
                                window.DisplayAllViews();
                                win.m_Parent.MakeVistaDWMHappyDance();
                            }
                            catch (Exception arg)
                            {
                                UnityEngine.Debug.Log("Maximization failed: " + arg);
                                WindowLayout.RevertFactorySettings();
                            }
                            try
                            {
                                if (Application.platform == RuntimePlatform.OSXEditor && SystemInfo.operatingSystem.Contains("10.7") && SystemInfo.graphicsDeviceVendor.Contains("ATI"))
                                {
                                    UnityEngine.Object[] array3 = Resources.FindObjectsOfTypeAll(typeof(GUIView));
                                    for (int j = 0; j < array3.Length; j++)
                                    {
                                        GUIView gUIView = (GUIView)array3[j];
                                        gUIView.Repaint();
                                    }
                                }
                            }
                            finally
                            {
                                ContainerWindow.SetFreezeDisplay(false);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        public static void Unmaximize(EditorWindow win)
        {
            HostView parent1 = win.m_Parent;

            if ((UnityEngine.Object)parent1 == (UnityEngine.Object)null)
            {
                UnityEngine.Debug.LogError((object)"Host view was not found");
                WindowLayout.RevertFactorySettings();
            }
            else
            {
                UnityEngine.Object[] objectArray = InternalEditorUtility.LoadSerializedFileAndForget(Path.Combine(WindowLayout.layoutsProjectPath, "CurrentMaximizeLayout.dwlt"));
                if (objectArray.Length < 2)
                {
                    UnityEngine.Debug.Log((object)"Maximized serialized file backup not found");
                    WindowLayout.RevertFactorySettings();
                }
                else
                {
                    SplitView    splitView = objectArray[0] as SplitView;
                    EditorWindow pane      = objectArray[1] as EditorWindow;
                    if ((UnityEngine.Object)splitView == (UnityEngine.Object)null)
                    {
                        UnityEngine.Debug.Log((object)"Maximization failed because the root split view was not found");
                        WindowLayout.RevertFactorySettings();
                    }
                    else
                    {
                        ContainerWindow window = win.m_Parent.window;
                        if ((UnityEngine.Object)window == (UnityEngine.Object)null)
                        {
                            UnityEngine.Debug.Log((object)"Maximization failed because the root split view has no container window");
                            WindowLayout.RevertFactorySettings();
                        }
                        else
                        {
                            try
                            {
                                ContainerWindow.SetFreezeDisplay(true);
                                if (!(bool)((UnityEngine.Object)parent1.parent))
                                {
                                    throw new Exception();
                                }
                                int  idx1     = parent1.parent.IndexOfChild((View)parent1);
                                Rect position = parent1.position;
                                View parent2  = parent1.parent;
                                parent2.RemoveChild(idx1);
                                parent2.AddChild((View)splitView, idx1);
                                splitView.position = position;
                                DockArea parent3 = pane.m_Parent as DockArea;
                                int      idx2    = parent3.m_Panes.IndexOf(pane);
                                parent1.actualView = (EditorWindow)null;
                                win.m_Parent       = (HostView)null;
                                parent3.AddTab(idx2, win);
                                parent3.RemoveTab(pane);
                                UnityEngine.Object.DestroyImmediate((UnityEngine.Object)pane);
                                foreach (UnityEngine.Object @object in objectArray)
                                {
                                    EditorWindow editorWindow = @object as EditorWindow;
                                    if ((UnityEngine.Object)editorWindow != (UnityEngine.Object)null)
                                    {
                                        editorWindow.MakeParentsSettingsMatchMe();
                                    }
                                }
                                parent2.Initialize(parent2.window);
                                parent2.position = parent2.position;
                                splitView.Reflow();
                                UnityEngine.Object.DestroyImmediate((UnityEngine.Object)parent1);
                                win.Focus();
                                window.DisplayAllViews();
                                win.m_Parent.MakeVistaDWMHappyDance();
                            }
                            catch (Exception ex)
                            {
                                UnityEngine.Debug.Log((object)("Maximization failed: " + (object)ex));
                                WindowLayout.RevertFactorySettings();
                            }
                            try
                            {
                                if (Application.platform != RuntimePlatform.OSXEditor || !SystemInfo.operatingSystem.Contains("10.7") || !SystemInfo.graphicsDeviceVendor.Contains("ATI"))
                                {
                                    return;
                                }
                                foreach (GUIView guiView in Resources.FindObjectsOfTypeAll(typeof(GUIView)))
                                {
                                    guiView.Repaint();
                                }
                            }
                            finally
                            {
                                ContainerWindow.SetFreezeDisplay(false);
                            }
                        }
                    }
                }
            }
        }