示例#1
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);
        }
示例#2
0
            static void InitializeProfilerSlaveProcess()
            {
                if (!File.Exists(userPrefProfilerLayoutPath) ||
                    File.GetLastWriteTime(systemProfilerLayoutPath) > File.GetLastWriteTime(userPrefProfilerLayoutPath))
                {
                    var parentDir = Path.GetDirectoryName(userPrefProfilerLayoutPath);
                    if (parentDir != null && !System.IO.Directory.Exists(parentDir))
                        System.IO.Directory.CreateDirectory(parentDir);
                    File.Copy(systemProfilerLayoutPath, userPrefProfilerLayoutPath, true);
                }
                WindowLayout.LoadWindowLayout(userPrefProfilerLayoutPath, false);

                SessionState.SetBool("OOPP.Initialized", true);
                EditorApplication.update -= InitializeProfilerSlaveProcessDomain;
                EditorApplication.update += InitializeProfilerSlaveProcessDomain;

                Console.WriteLine("[UMPE] Initialize Profiler Slave Process");
            }
示例#3
0
            static void InitializeProfilerSlaveProcess()
            {
                if (!File.Exists(userPrefProfilerLayoutPath) ||
                    File.GetLastWriteTime(systemProfilerLayoutPath) > File.GetLastWriteTime(userPrefProfilerLayoutPath))
                {
                    var parentDir = Path.GetDirectoryName(userPrefProfilerLayoutPath);
                    if (parentDir != null && !System.IO.Directory.Exists(parentDir))
                    {
                        System.IO.Directory.CreateDirectory(parentDir);
                    }
                    File.Copy(systemProfilerLayoutPath, userPrefProfilerLayoutPath, true);
                }
                WindowLayout.LoadWindowLayout(userPrefProfilerLayoutPath, false);

                s_SlaveProfilerWindow = EditorWindow.GetWindowDontShow <ProfilerWindow>();
                SetupProfilerWindow(s_SlaveProfilerWindow);
                EditorApplication.delayCall += SetupProfilerDriver;
            }
示例#4
0
 internal static void InitPlaymodeLayout()
 {
     EditorApplicationLayout.m_GameView = WindowLayout.ShowAppropriateViewOnEnterExitPlaymode(true) as GameView;
     if ((Object)EditorApplicationLayout.m_GameView == (Object)null)
     {
         return;
     }
     if (EditorApplicationLayout.m_GameView.maximizeOnPlay)
     {
         DockArea parent = EditorApplicationLayout.m_GameView.m_Parent as DockArea;
         if ((Object)parent != (Object)null && !parent.actualView.m_Parent.window.maximized)
         {
             EditorApplicationLayout.m_RootSplit = WindowLayout.MaximizePrepare(parent.actualView);
         }
     }
     EditorApplicationLayout.m_GameView.m_Parent.SetAsStartView();
     Toolbar.RepaintToolbar();
 }
示例#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
        public static void AddSplitViewAndChildrenRecurse(View splitview, ArrayList list)
        {
            list.Add((object)splitview);
            DockArea dockArea = splitview as DockArea;

            if ((UnityEngine.Object)dockArea != (UnityEngine.Object)null)
            {
                list.AddRange((ICollection)dockArea.m_Panes);
            }
            if ((UnityEngine.Object)(splitview as DockArea) != (UnityEngine.Object)null)
            {
                list.Add((object)dockArea.actualView);
            }
            foreach (View child in splitview.children)
            {
                WindowLayout.AddSplitViewAndChildrenRecurse(child, list);
            }
        }
示例#7
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);
            }
        }
示例#8
0
        internal static EditorWindow TryFocusAppropriateWindow(bool enteringPlaymode)
        {
            if (enteringPlaymode)
            {
                GameView gameView = (GameView)WindowLayout.FindEditorWindowOfType(typeof(GameView));
                if (gameView)
                {
                    WindowLayout.SaveCurrentFocusedWindowInSameDock(gameView);
                    gameView.Focus();
                }
                return(gameView);
            }
            EditorWindow editorWindow = WindowLayout.TryGetLastFocusedWindowInSameDock();

            if (editorWindow)
            {
                editorWindow.ShowTab();
            }
            return(editorWindow);
        }
        // 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
        internal static EditorWindow TryFocusAppropriateWindow(bool enteringPlaymode)
        {
            if (enteringPlaymode)
            {
                GameView editorWindowOfType = (GameView)WindowLayout.FindEditorWindowOfType(typeof(GameView));
                if ((bool)((UnityEngine.Object)editorWindowOfType))
                {
                    WindowLayout.SaveCurrentFocusedWindowInSameDock((EditorWindow)editorWindowOfType);
                    editorWindowOfType.Focus();
                }
                return((EditorWindow)editorWindowOfType);
            }
            EditorWindow windowInSameDock = WindowLayout.TryGetLastFocusedWindowInSameDock();

            if ((bool)((UnityEngine.Object)windowInSameDock))
            {
                windowInSameDock.ShowTab();
            }
            return(windowInSameDock);
        }
示例#11
0
 private void ClickEnableFrameDebugger()
 {
     if (GraphicsSupportsFrameDebugger())
     {
         if ((!FrameDebuggerUtility.enabled && EditorApplication.isPlaying) && !EditorApplication.isPaused)
         {
             EditorApplication.isPaused = true;
         }
         FrameDebuggerUtility.enabled = !FrameDebuggerUtility.enabled;
         if (FrameDebuggerUtility.enabled)
         {
             GameView view = (GameView)WindowLayout.FindEditorWindowOfType(typeof(GameView));
             if (view != null)
             {
                 view.ShowTab();
             }
         }
         this.m_PrevEventsLimit = FrameDebuggerUtility.limit;
         this.m_PrevEventsCount = FrameDebuggerUtility.count;
     }
 }
示例#12
0
 internal static void InitPlaymodeLayout()
 {
     EditorApplicationLayout.m_GameView = (WindowLayout.ShowAppropriateViewOnEnterExitPlaymode(true) as GameView);
     if (!(EditorApplicationLayout.m_GameView == null))
     {
         if (EditorApplicationLayout.m_GameView.maximizeOnPlay)
         {
             DockArea dockArea = EditorApplicationLayout.m_GameView.m_Parent as DockArea;
             if (dockArea != null)
             {
                 ContainerWindow window = dockArea.actualView.m_Parent.window;
                 if (!window.maximized)
                 {
                     EditorApplicationLayout.m_MaximizePending = WindowLayout.MaximizePrepare(dockArea.actualView);
                 }
             }
         }
         EditorApplicationLayout.m_GameView.m_Parent.SetAsStartView();
         Toolbar.RepaintToolbar();
     }
 }
示例#13
0
        private static void OnModeChangeLayouts(ModeChangedArgs args)
        {
            // Prevent double loading the default/last layout already done by the WindowLayout system.
            if (args.prevIndex == -1)
            {
                return;
            }

            if (!HasCapability(ModeCapability.LayoutSwitching, true))
            {
                return;
            }

            // Save previous mode layout
            var prevLayoutPath = Path.Combine(Application.temporaryCachePath, $"{k_ModeLayoutKeyName}-{GetModeId(args.prevIndex)}.wlt");

            WindowLayout.SaveWindowLayout(prevLayoutPath);

            // Load exiting layout if available
            var modeLayoutPath = Path.Combine(Application.temporaryCachePath, $"{k_ModeLayoutKeyName}-{GetModeId(args.nextIndex)}.wlt");

            if (File.Exists(modeLayoutPath))
            {
                WindowLayout.LoadWindowLayout(modeLayoutPath, false, false);
            }
            else
            {
                var layouts = GetModeDataSection(args.nextIndex, k_LayoutsSectionName) as IList <object>;
                if (layouts != null && layouts.Count > 0)
                {
                    var layoutPath = layouts[0] as string;
                    if (layoutPath != null)
                    {
                        WindowLayout.LoadWindowLayout(layoutPath, false, false);
                    }
                }
            }

            WindowLayout.ReloadWindowLayoutMenu();
        }
示例#14
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)
         {
             if (!(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)
                     {
                         if (!WindowLayout.IsMaximized(mouseOverWindow))
                         {
                             WindowLayout.Maximize(mouseOverWindow);
                         }
                     }
                 }
                 else if (WindowLayout.IsMaximized(mouseOverWindow))
                 {
                     WindowLayout.Unmaximize(mouseOverWindow);
                 }
                 else
                 {
                     WindowLayout.Maximize(mouseOverWindow);
                 }
             }
         }
     }
 }
示例#15
0
        public static void AddSplitViewAndChildrenRecurse(View splitview, ArrayList list)
        {
            list.Add(splitview);
            DockArea dockArea = splitview as DockArea;

            if (dockArea != null)
            {
                list.AddRange(dockArea.m_Panes);
            }
            HostView x = splitview as DockArea;

            if (x != null)
            {
                list.Add(dockArea.actualView);
            }
            View[] children = splitview.children;
            for (int i = 0; i < children.Length; i++)
            {
                View splitview2 = children[i];
                WindowLayout.AddSplitViewAndChildrenRecurse(splitview2, list);
            }
        }
        static internal void SetStopmodeLayout()
        {
            if (m_PlayModeViewList != null && m_PlayModeViewList.Count > 0)
            {
                var monitorNames = EditorFullscreenController.GetConnectedDisplayNames();
                foreach (var playModeView in m_PlayModeViewList)
                {
                    if (playModeView.fullscreenMonitorIdx >= monitorNames.Length)
                    {
                        continue;
                    }

                    EditorFullscreenController.SetSettingsForCurrentDisplay(playModeView.fullscreenMonitorIdx);
                    EditorFullscreenController.OnExitPlaymode();
                }

                m_PlayModeViewList.Clear();
                m_PlayModeViewList = null;
            }

            WindowLayout.ShowAppropriateViewOnEnterExitPlaymode(false);
            Toolbar.RepaintToolbar();
        }
示例#17
0
        private void OnGUI()
        {
            GUILayout.Space(5f);
            Event current = Event.current;
            bool  flag    = (current.type == EventType.KeyDown) && ((current.keyCode == KeyCode.Return) || (current.keyCode == KeyCode.KeypadEnter));

            GUI.SetNextControlName("m_PreferencesName");
            this.m_LayoutName = EditorGUILayout.TextField(this.m_LayoutName, new GUILayoutOption[0]);
            if (!this.didFocus)
            {
                this.didFocus = true;
                EditorGUI.FocusTextInControl("m_PreferencesName");
            }
            GUI.enabled = this.m_LayoutName.Length != 0;
            if (GUILayout.Button("Save", new GUILayoutOption[0]) || flag)
            {
                base.Close();
                string path = Path.Combine(WindowLayout.layoutsPreferencesPath, this.m_LayoutName + ".wlt");
                Toolbar.lastLoadedLayoutName = this.m_LayoutName;
                WindowLayout.SaveWindowLayout(path);
                InternalEditorUtility.ReloadWindowLayoutMenu();
                GUIUtility.ExitGUI();
            }
        }
        static internal void InitPlaymodeLayout()
        {
            m_PreviewWindow = WindowLayout.ShowAppropriateViewOnEnterExitPlaymode(true) as PreviewEditorWindow;
            if (m_PreviewWindow == null)
            {
                return;
            }

            if (m_PreviewWindow.maximizeOnPlay)
            {
                DockArea da = m_PreviewWindow.m_Parent as DockArea;

                if (da != null)
                {
                    m_MaximizePending = WindowLayout.MaximizePrepare(da.actualView);
                }
            }

            // Mark this preview window as the start preview so the backend
            // can set size and mouseoffset properly for this preview
            m_PreviewWindow.m_Parent.SetAsStartView();

            Toolbar.RepaintToolbar();
        }
示例#19
0
        public static bool MaximizePrepare(EditorWindow win)
        {
            View parent = win.m_Parent.parent;
            View view   = parent;

            while (parent != null && parent is SplitView)
            {
                view   = parent;
                parent = parent.parent;
            }
            DockArea dockArea = win.m_Parent as DockArea;
            bool     result;

            if (dockArea == null)
            {
                result = false;
            }
            else if (parent == null)
            {
                result = false;
            }
            else
            {
                MainView x = view.parent as MainView;
                if (x == null)
                {
                    result = false;
                }
                else
                {
                    ContainerWindow window = win.m_Parent.window;
                    if (window == null)
                    {
                        result = false;
                    }
                    else
                    {
                        int num = dockArea.m_Panes.IndexOf(win);
                        if (num == -1)
                        {
                            result = false;
                        }
                        else
                        {
                            dockArea.selected = num;
                            WindowLayout.SaveSplitViewAndChildren(view, win, Path.Combine(WindowLayout.layoutsProjectPath, "CurrentMaximizeLayout.dwlt"));
                            dockArea.actualView   = null;
                            dockArea.m_Panes[num] = null;
                            MaximizedHostView maximizedHostView = ScriptableObject.CreateInstance <MaximizedHostView>();
                            int  idx      = parent.IndexOfChild(view);
                            Rect position = view.position;
                            parent.RemoveChild(view);
                            parent.AddChild(maximizedHostView, idx);
                            maximizedHostView.actualView = win;
                            maximizedHostView.position   = position;
                            UnityEngine.Object.DestroyImmediate(view, true);
                            result = true;
                        }
                    }
                }
            }
            return(result);
        }
示例#20
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);
                            }
                        }
                    }
                }
            }
        }
示例#21
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);
        }
示例#22
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);
        }
示例#23
0
 static internal void SetStopmodeLayout()
 {
     WindowLayout.ShowAppropriateViewOnEnterExitPlaymode(false);
     Toolbar.RepaintToolbar();
 }
示例#24
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);
        }
示例#25
0
        private void Maximize(object userData)
        {
            EditorWindow win = (EditorWindow)userData;

            WindowLayout.Maximize(win);
        }
示例#26
0
 private void Maximize(object userData)
 {
     WindowLayout.Maximize((EditorWindow)userData);
 }
示例#27
0
        void Unmaximize(object userData)
        {
            EditorWindow ew = ((EditorWindow)userData);

            WindowLayout.Unmaximize(ew);
        }
示例#28
0
        public static bool LoadWindowLayout(string path)
        {
            bool newProjectLayoutWasCreated = false;

            return(WindowLayout.LoadWindowLayout(path, newProjectLayoutWasCreated));
        }
示例#29
0
 public static bool LoadWindowLayout(string path)
 {
     return(WindowLayout.LoadWindowLayout(path, false));
 }
        static internal void InitPlaymodeLayout()
        {
            InitializePlaymodeViewList();
            WindowLayout.ShowAppropriateViewOnEnterExitPlaymodeList(true, out m_PlayModeViewList);

            var fullscreenDetected = false;
            var monitorNames       = EditorFullscreenController.GetConnectedDisplayNames();

            foreach (var playModeView in m_PlayModeViewList)
            {
                if (playModeView == null)
                {
                    continue;
                }

                if (playModeView.fullscreenMonitorIdx >= monitorNames.Length)
                {
                    continue;
                }

                if (playModeView.enterPlayModeBehavior == PlayModeView.EnterPlayModeBehavior.PlayFullscreen)
                {
                    EditorFullscreenController.SetSettingsForCurrentDisplay(playModeView.fullscreenMonitorIdx);
                    EditorFullscreenController.isFullscreenOnPlay           = true;
                    EditorFullscreenController.fullscreenDisplayId          = playModeView.fullscreenMonitorIdx;
                    EditorFullscreenController.isToolbarEnabledOnFullscreen = false;
                    EditorFullscreenController.targetDisplayID = playModeView.targetDisplay;

                    if (playModeView.m_Parent is DockArea dockArea && dockArea.actualView is GameView gv)
                    {
                        playModeView.m_Parent.EnableVSync(gv.vSyncEnabled);
                        EditorFullscreenController.enableVSync       = gv.vSyncEnabled;
                        EditorFullscreenController.selectedSizeIndex = gv.selectedSizeIndex;
                    }
                    fullscreenDetected = true;
                }
                else if (!fullscreenDetected)
                {
                    EditorFullscreenController.isFullscreenOnPlay = false;
                }

                if (playModeView.enterPlayModeBehavior == PlayModeView.EnterPlayModeBehavior.PlayMaximized)
                {
                    if (playModeView.m_Parent is DockArea dockArea)
                    {
                        m_MaximizePending = WindowLayout.MaximizePrepare(dockArea.actualView);
                        var gv = dockArea.actualView as GameView;
                        if (gv != null)
                        {
                            playModeView.m_Parent.EnableVSync(gv.vSyncEnabled);
                        }
                    }
                }

                EditorFullscreenController.OnEnterPlaymode();

                if (!EditorFullscreenController.isFullscreenOnPlay)
                {
                    playModeView.m_Parent.SetAsStartView();
                    playModeView.m_Parent.SetAsLastPlayModeView();

                    if (playModeView.maximized)
                    {
                        playModeView.m_Parent.Focus();
                    }

                    if (playModeView is IGameViewOnPlayMenuUser)
                    {
                        if (((IGameViewOnPlayMenuUser)playModeView).playFocused)
                        {
                            playModeView.m_Parent.Focus();
                        }
                    }
                }
                Toolbar.RepaintToolbar();
            }
        }