コード例 #1
0
 internal static void MaximizeKeyHandler()
 {
     if ((WindowLayout.s_MaximizeKey.activated || Event.current.type == EditorGUIUtility.magnifyGestureEventType) && GUIUtility.hotControl == 0)
     {
         EventType type = Event.current.type;
         Event.current.Use();
         EditorWindow mouseOverWindow = EditorWindow.mouseOverWindow;
         if (mouseOverWindow && !(mouseOverWindow is PreviewWindow))
         {
             if (type == EditorGUIUtility.magnifyGestureEventType)
             {
                 if ((double)Event.current.delta.x < -0.05)
                 {
                     if (WindowLayout.IsMaximized(mouseOverWindow))
                     {
                         WindowLayout.Unmaximize(mouseOverWindow);
                     }
                 }
                 else if ((double)Event.current.delta.x > 0.05 && !WindowLayout.IsMaximized(mouseOverWindow))
                 {
                     WindowLayout.Maximize(mouseOverWindow);
                 }
             }
             else if (WindowLayout.IsMaximized(mouseOverWindow))
             {
                 WindowLayout.Unmaximize(mouseOverWindow);
             }
             else
             {
                 WindowLayout.Maximize(mouseOverWindow);
             }
         }
     }
 }
コード例 #2
0
        // Close the editor window.
        public void Close()
        {
            // Guard against multiple call to Close in the same stack
            // (since we call DestroyImmediate at the end of Close()).
            if (!this)
            {
                return;
            }

            // Ensure to restore normal workspace before destroying. Fix case 406657.
            if (WindowLayout.IsMaximized(this))
            {
                WindowLayout.Unmaximize(this);
            }

            DockArea da = m_Parent as DockArea;

            if (da)
            {
                da.RemoveTab(this, true);
            }
            else
            {
                m_Parent.window.Close();
            }
            UnityEngine.Object.DestroyImmediate(this, true);
            EditorWindow.UpdateWindowMenuListing();
        }
コード例 #3
0
        internal static EditorWindow ShowAppropriateViewOnEnterExitPlaymode(bool entering)
        {
            if (WindowFocusState.instance.m_CurrentlyInPlayMode == entering)
            {
                return(null);
            }
            WindowFocusState.instance.m_CurrentlyInPlayMode = entering;
            EditorWindow maximizedWindow = WindowLayout.GetMaximizedWindow();

            if (entering)
            {
                WindowFocusState.instance.m_WasMaximizedBeforePlay = (maximizedWindow != null);
                if (maximizedWindow != null)
                {
                    return(maximizedWindow);
                }
            }
            else
            {
                if (WindowFocusState.instance.m_WasMaximizedBeforePlay)
                {
                    return(maximizedWindow);
                }
            }
            if (maximizedWindow)
            {
                WindowLayout.Unmaximize(maximizedWindow);
            }
            EditorWindow editorWindow = WindowLayout.TryFocusAppropriateWindow(entering);

            if (editorWindow)
            {
                return(editorWindow);
            }
            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);
                        return(gameView);
                    }
                }
                gameView = ScriptableObject.CreateInstance <GameView>();
                gameView.Show(true);
                gameView.Focus();
                return(gameView);
            }
            return(editorWindow);
        }
コード例 #4
0
        internal static EditorWindow ShowAppropriateViewOnEnterExitPlaymode(bool entering)
        {
            if (WindowFocusState.instance.m_CurrentlyInPlayMode == entering)
            {
                return((EditorWindow)null);
            }
            WindowFocusState.instance.m_CurrentlyInPlayMode = entering;
            EditorWindow maximizedWindow = WindowLayout.GetMaximizedWindow();

            if (entering)
            {
                WindowFocusState.instance.m_WasMaximizedBeforePlay = (UnityEngine.Object)maximizedWindow != (UnityEngine.Object)null;
                if ((UnityEngine.Object)maximizedWindow != (UnityEngine.Object)null)
                {
                    return(maximizedWindow);
                }
            }
            else if (WindowFocusState.instance.m_WasMaximizedBeforePlay)
            {
                return(maximizedWindow);
            }
            if ((bool)((UnityEngine.Object)maximizedWindow))
            {
                WindowLayout.Unmaximize(maximizedWindow);
            }
            EditorWindow editorWindow = WindowLayout.TryFocusAppropriateWindow(entering);

            if ((bool)((UnityEngine.Object)editorWindow) || !entering)
            {
                return(editorWindow);
            }
            EditorWindow editorWindowOfType = WindowLayout.FindEditorWindowOfType(typeof(SceneView));

            if ((bool)((UnityEngine.Object)editorWindowOfType) && editorWindowOfType.m_Parent is DockArea)
            {
                DockArea parent = editorWindowOfType.m_Parent as DockArea;
                if ((bool)((UnityEngine.Object)parent))
                {
                    WindowFocusState.instance.m_LastWindowTypeInSameDock = editorWindowOfType.GetType().ToString();
                    GameView instance = ScriptableObject.CreateInstance <GameView>();
                    parent.AddTab((EditorWindow)instance);
                    return((EditorWindow)instance);
                }
            }
            GameView instance1 = ScriptableObject.CreateInstance <GameView>();

            instance1.Show(true);
            instance1.Focus();
            return((EditorWindow)instance1);
        }
コード例 #5
0
        public void Close()
        {
            if (WindowLayout.IsMaximized(this))
            {
                WindowLayout.Unmaximize(this);
            }
            DockArea dockArea = this.m_Parent as DockArea;

            if (dockArea)
            {
                dockArea.RemoveTab(this, true);
            }
            else
            {
                this.m_Parent.window.Close();
            }
            UnityEngine.Object.DestroyImmediate(this, true);
        }
コード例 #6
0
        /// <summary>
        ///   <para>Close the editor window.</para>
        /// </summary>
        public void Close()
        {
            if (WindowLayout.IsMaximized(this))
            {
                WindowLayout.Unmaximize(this);
            }
            DockArea parent = this.m_Parent as DockArea;

            if ((bool)((UnityEngine.Object)parent))
            {
                parent.RemoveTab(this, true);
            }
            else
            {
                this.m_Parent.window.Close();
            }
            UnityEngine.Object.DestroyImmediate((UnityEngine.Object) this, true);
        }
コード例 #7
0
        public void Close()
        {
            if (WindowLayout.IsMaximized(this))
            {
                WindowLayout.Unmaximize(this);
            }
            DockArea parent = this.m_Parent as DockArea;

            if (parent != null)
            {
                parent.RemoveTab(this, true);
            }
            else
            {
                this.m_Parent.window.Close();
            }
            Object.DestroyImmediate(this, true);
        }
コード例 #8
0
        internal static void MaximizeKeyHandler()
        {
            if (!WindowLayout.s_MaximizeKey.activated && Event.current.type != EditorGUIUtility.magnifyGestureEventType || GUIUtility.hotControl != 0)
            {
                return;
            }
            EventType type = Event.current.type;

            Event.current.Use();
            EditorWindow mouseOverWindow = EditorWindow.mouseOverWindow;

            if (!(bool)((UnityEngine.Object)mouseOverWindow) || mouseOverWindow is PreviewWindow)
            {
                return;
            }
            if (type == EditorGUIUtility.magnifyGestureEventType)
            {
                if ((double)Event.current.delta.x < -0.05)
                {
                    if (!WindowLayout.IsMaximized(mouseOverWindow))
                    {
                        return;
                    }
                    WindowLayout.Unmaximize(mouseOverWindow);
                }
                else
                {
                    if ((double)Event.current.delta.x <= 0.05 || WindowLayout.IsMaximized(mouseOverWindow))
                    {
                        return;
                    }
                    WindowLayout.Maximize(mouseOverWindow);
                }
            }
            else if (WindowLayout.IsMaximized(mouseOverWindow))
            {
                WindowLayout.Unmaximize(mouseOverWindow);
            }
            else
            {
                WindowLayout.Maximize(mouseOverWindow);
            }
        }
コード例 #9
0
        // Close the editor window.
        public void Close()
        {
            // Ensure to restore normal workspace before destroying. Fix case 406657.
            if (WindowLayout.IsMaximized(this))
            {
                WindowLayout.Unmaximize(this);
            }

            DockArea da = m_Parent as DockArea;

            if (da)
            {
                da.RemoveTab(this, true);
            }
            else
            {
                m_Parent.window.Close();
            }
            UnityEngine.Object.DestroyImmediate(this, true);
        }
コード例 #10
0
        public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated)
        {
            Rect position = default(Rect);

            UnityEngine.Object[] array  = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow));
            UnityEngine.Object[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                ContainerWindow containerWindow = (ContainerWindow)array2[i];
                if (containerWindow.showMode == ShowMode.MainWindow)
                {
                    position = containerWindow.position;
                }
            }
            bool result;

            try
            {
                ContainerWindow.SetFreezeDisplay(true);
                WindowLayout.CloseWindows();
                UnityEngine.Object[]      array3 = InternalEditorUtility.LoadSerializedFileAndForget(path);
                List <UnityEngine.Object> list   = new List <UnityEngine.Object>();
                int j = 0;
                while (j < array3.Length)
                {
                    UnityEngine.Object @object      = array3[j];
                    EditorWindow       editorWindow = @object as EditorWindow;
                    if (editorWindow != null)
                    {
                        if (!(editorWindow.m_Parent == null))
                        {
                            goto IL_17D;
                        }
                        UnityEngine.Object.DestroyImmediate(editorWindow, true);
                        UnityEngine.Debug.LogError(string.Concat(new object[]
                        {
                            "Removed unparented EditorWindow while reading window layout: window #",
                            j,
                            ", type=",
                            @object.GetType().ToString(),
                            ", instanceID=",
                            @object.GetInstanceID()
                        }));
                    }
                    else
                    {
                        DockArea dockArea = @object as DockArea;
                        if (!(dockArea != null) || dockArea.m_Panes.Count != 0)
                        {
                            goto IL_17D;
                        }
                        dockArea.Close(null);
                        UnityEngine.Debug.LogError(string.Concat(new object[]
                        {
                            "Removed empty DockArea while reading window layout: window #",
                            j,
                            ", instanceID=",
                            @object.GetInstanceID()
                        }));
                    }
IL_187:
                    j++;
                    continue;
IL_17D:
                    list.Add(@object);
                    goto IL_187;
                }
                ContainerWindow containerWindow2 = null;
                ContainerWindow containerWindow3 = null;
                for (int k = 0; k < list.Count; k++)
                {
                    ContainerWindow containerWindow4 = list[k] as ContainerWindow;
                    if (containerWindow4 != null && containerWindow4.showMode == ShowMode.MainWindow)
                    {
                        containerWindow3 = containerWindow4;
                        if ((double)position.width != 0.0)
                        {
                            containerWindow2          = containerWindow4;
                            containerWindow2.position = position;
                        }
                    }
                }
                for (int l = 0; l < list.Count; l++)
                {
                    UnityEngine.Object object2 = list[l];
                    if (object2 == null)
                    {
                        UnityEngine.Debug.LogError("Error while reading window layout: window #" + l + " is null");
                    }
                    else if (object2.GetType() == null)
                    {
                        UnityEngine.Debug.LogError(string.Concat(new object[]
                        {
                            "Error while reading window layout: window #",
                            l,
                            " type is null, instanceID=",
                            object2.GetInstanceID()
                        }));
                    }
                    else if (newProjectLayoutWasCreated)
                    {
                        MethodInfo method = object2.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                        if (method != null)
                        {
                            method.Invoke(object2, null);
                        }
                    }
                }
                if (containerWindow2)
                {
                    containerWindow2.position = position;
                    containerWindow2.OnResize();
                }
                if (containerWindow3 == null)
                {
                    UnityEngine.Debug.LogError("Error while reading window layout: no main window found");
                    throw new Exception();
                }
                containerWindow3.Show(containerWindow3.showMode, true, true);
                for (int m = 0; m < list.Count; m++)
                {
                    EditorWindow editorWindow2 = list[m] as EditorWindow;
                    if (editorWindow2)
                    {
                        editorWindow2.minSize = editorWindow2.minSize;
                    }
                    ContainerWindow containerWindow5 = list[m] as ContainerWindow;
                    if (containerWindow5 && containerWindow5 != containerWindow3)
                    {
                        containerWindow5.Show(containerWindow5.showMode, true, true);
                    }
                }
                GameView gameView = WindowLayout.GetMaximizedWindow() as GameView;
                if (gameView != null && gameView.maximizeOnPlay)
                {
                    WindowLayout.Unmaximize(gameView);
                }
                if (newProjectLayoutWasCreated)
                {
                    if (UnityConnect.instance.online && UnityConnect.instance.loggedIn && UnityConnect.instance.shouldShowServicesWindow)
                    {
                        UnityConnectServiceCollection.instance.ShowService("Hub", true);
                    }
                    else
                    {
                        UnityConnectServiceCollection.instance.CloseServices();
                    }
                }
            }
            catch (Exception arg)
            {
                UnityEngine.Debug.LogError("Failed to load window layout: " + arg);
                int num = 0;
                if (!Application.isTestRun)
                {
                    num = EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings");
                }
                if (num != 0)
                {
                    if (num != 1)
                    {
                        if (num == 2)
                        {
                            WindowLayout.RevertFactorySettings();
                        }
                    }
                    else
                    {
                        EditorApplication.Exit(0);
                    }
                }
                else
                {
                    WindowLayout.LoadDefaultLayout();
                }
                result = false;
                return(result);
            }
            finally
            {
                ContainerWindow.SetFreezeDisplay(false);
                if (Path.GetExtension(path) == ".wlt")
                {
                    Toolbar.lastLoadedLayoutName = Path.GetFileNameWithoutExtension(path);
                }
                else
                {
                    Toolbar.lastLoadedLayoutName = null;
                }
            }
            result = true;
            return(result);
        }
コード例 #11
0
        void Unmaximize(object userData)
        {
            EditorWindow ew = ((EditorWindow)userData);

            WindowLayout.Unmaximize(ew);
        }
コード例 #12
0
        private void Unmaximize(object userData)
        {
            EditorWindow win = (EditorWindow)userData;

            WindowLayout.Unmaximize(win);
        }
コード例 #13
0
        public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated)
        {
            Rect position = default(Rect);

            UnityEngine.Object[] array  = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow));
            UnityEngine.Object[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                ContainerWindow containerWindow = (ContainerWindow)array2[i];
                if (containerWindow.showMode == ShowMode.MainWindow)
                {
                    position = containerWindow.position;
                }
            }
            try
            {
                ContainerWindow.SetFreezeDisplay(true);
                WindowLayout.CloseWindows();
                UnityEngine.Object[] array3           = InternalEditorUtility.LoadSerializedFileAndForget(path);
                ContainerWindow      containerWindow2 = null;
                ContainerWindow      containerWindow3 = null;
                UnityEngine.Object[] array4           = array3;
                for (int j = 0; j < array4.Length; j++)
                {
                    UnityEngine.Object @object          = array4[j];
                    ContainerWindow    containerWindow4 = @object as ContainerWindow;
                    if (containerWindow4 != null && containerWindow4.showMode == ShowMode.MainWindow)
                    {
                        containerWindow3 = containerWindow4;
                        if ((double)position.width != 0.0)
                        {
                            containerWindow2          = containerWindow4;
                            containerWindow2.position = position;
                        }
                    }
                }
                int num = 0;
                UnityEngine.Object[] array5 = array3;
                for (int k = 0; k < array5.Length; k++)
                {
                    UnityEngine.Object object2 = array5[k];
                    if (object2 == null)
                    {
                        UnityEngine.Debug.LogError("Error while reading window layout: window #" + num + " is null");
                        throw new Exception();
                    }
                    if (object2.GetType() == null)
                    {
                        UnityEngine.Debug.LogError(string.Concat(new object[]
                        {
                            "Error while reading window layout: window #",
                            num,
                            " type is null, instanceID=",
                            object2.GetInstanceID()
                        }));
                        throw new Exception();
                    }
                    if (newProjectLayoutWasCreated)
                    {
                        MethodInfo method = object2.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                        if (method != null)
                        {
                            method.Invoke(object2, null);
                        }
                    }
                    num++;
                }
                if (containerWindow2)
                {
                    containerWindow2.position = position;
                    containerWindow2.OnResize();
                }
                if (containerWindow3 == null)
                {
                    UnityEngine.Debug.LogError("Error while reading window layout: no main window found");
                    throw new Exception();
                }
                containerWindow3.Show(containerWindow3.showMode, true, true);
                UnityEngine.Object[] array6 = array3;
                for (int l = 0; l < array6.Length; l++)
                {
                    UnityEngine.Object object3      = array6[l];
                    EditorWindow       editorWindow = object3 as EditorWindow;
                    if (editorWindow)
                    {
                        editorWindow.minSize = editorWindow.minSize;
                    }
                    ContainerWindow containerWindow5 = object3 as ContainerWindow;
                    if (containerWindow5 && containerWindow5 != containerWindow3)
                    {
                        containerWindow5.Show(containerWindow5.showMode, true, true);
                    }
                }
                GameView gameView = WindowLayout.GetMaximizedWindow() as GameView;
                if (gameView != null && gameView.maximizeOnPlay)
                {
                    WindowLayout.Unmaximize(gameView);
                }
            }
            catch (Exception arg)
            {
                UnityEngine.Debug.LogError("Failed to load window layout: " + arg);
                switch (EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings"))
                {
                case 0:
                    WindowLayout.LoadDefaultLayout();
                    break;

                case 1:
                    EditorApplication.Exit(0);
                    break;

                case 2:
                    WindowLayout.RevertFactorySettings();
                    break;
                }
                return(false);
            }
            finally
            {
                ContainerWindow.SetFreezeDisplay(false);
                if (Path.GetExtension(path) == ".wlt")
                {
                    Toolbar.lastLoadedLayoutName = Path.GetFileNameWithoutExtension(path);
                }
                else
                {
                    Toolbar.lastLoadedLayoutName = null;
                }
            }
            return(true);
        }
コード例 #14
0
 private void Unmaximize(object userData)
 {
     WindowLayout.Unmaximize((EditorWindow)userData);
 }
コード例 #15
0
        public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated)
        {
            Rect rect = new Rect();

            foreach (ContainerWindow containerWindow in Resources.FindObjectsOfTypeAll(typeof(ContainerWindow)))
            {
                if (containerWindow.showMode == ShowMode.MainWindow)
                {
                    rect = containerWindow.position;
                }
            }
            try
            {
                ContainerWindow.SetFreezeDisplay(true);
                WindowLayout.CloseWindows();
                UnityEngine.Object[] objectArray      = InternalEditorUtility.LoadSerializedFileAndForget(path);
                ContainerWindow      containerWindow1 = (ContainerWindow)null;
                ContainerWindow      containerWindow2 = (ContainerWindow)null;
                foreach (UnityEngine.Object @object in objectArray)
                {
                    ContainerWindow containerWindow3 = @object as ContainerWindow;
                    if ((UnityEngine.Object)containerWindow3 != (UnityEngine.Object)null && containerWindow3.showMode == ShowMode.MainWindow)
                    {
                        containerWindow2 = containerWindow3;
                        if ((double)rect.width != 0.0)
                        {
                            containerWindow1          = containerWindow3;
                            containerWindow1.position = rect;
                        }
                    }
                }
                int num = 0;
                foreach (UnityEngine.Object @object in objectArray)
                {
                    if (@object == (UnityEngine.Object)null)
                    {
                        UnityEngine.Debug.LogError((object)("Error while reading window layout: window #" + (object)num + " is null"));
                        throw new Exception();
                    }
                    if (@object.GetType() == null)
                    {
                        UnityEngine.Debug.LogError((object)("Error while reading window layout: window #" + (object)num + " type is null, instanceID=" + (object)@object.GetInstanceID()));
                        throw new Exception();
                    }
                    if (newProjectLayoutWasCreated)
                    {
                        MethodInfo method = @object.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                        if (method != null)
                        {
                            method.Invoke((object)@object, (object[])null);
                        }
                    }
                    ++num;
                }
                if ((bool)((UnityEngine.Object)containerWindow1))
                {
                    containerWindow1.position = rect;
                    containerWindow1.OnResize();
                }
                if ((UnityEngine.Object)containerWindow2 == (UnityEngine.Object)null)
                {
                    UnityEngine.Debug.LogError((object)"Error while reading window layout: no main window found");
                    throw new Exception();
                }
                containerWindow2.Show(containerWindow2.showMode, true, true);
                foreach (UnityEngine.Object @object in objectArray)
                {
                    EditorWindow editorWindow = @object as EditorWindow;
                    if ((bool)((UnityEngine.Object)editorWindow))
                    {
                        editorWindow.minSize = editorWindow.minSize;
                    }
                    ContainerWindow containerWindow3 = @object as ContainerWindow;
                    if ((bool)((UnityEngine.Object)containerWindow3) && (UnityEngine.Object)containerWindow3 != (UnityEngine.Object)containerWindow2)
                    {
                        containerWindow3.Show(containerWindow3.showMode, true, true);
                    }
                }
                GameView maximizedWindow = WindowLayout.GetMaximizedWindow() as GameView;
                if ((UnityEngine.Object)maximizedWindow != (UnityEngine.Object)null)
                {
                    if (maximizedWindow.maximizeOnPlay)
                    {
                        WindowLayout.Unmaximize((EditorWindow)maximizedWindow);
                    }
                }
            }
            catch (Exception ex)
            {
                UnityEngine.Debug.LogError((object)("Failed to load window layout: " + (object)ex));
                switch (EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings"))
                {
                case 0:
                    WindowLayout.LoadDefaultLayout();
                    break;

                case 1:
                    EditorApplication.Exit(0);
                    break;

                case 2:
                    WindowLayout.RevertFactorySettings();
                    break;
                }
                return(false);
            }
            finally
            {
                ContainerWindow.SetFreezeDisplay(false);
                Toolbar.lastLoadedLayoutName = !(Path.GetExtension(path) == ".wlt") ? (string)null : Path.GetFileNameWithoutExtension(path);
            }
            return(true);
        }