private static WindowFullscreenState AddWindowState(EditorWindow editorWin, Type windowType, Type actualType) { var winState = new WindowFullscreenState(); winState.WindowType = windowType; winState.ActualType = actualType; if (editorWin != null) { winState.SetEditorWin(editorWin); } else if (windowType == mainWindowType) { winState.WindowName = mainWindowType.Name; winState.WindowTitle = "Unity Editor"; winState.containerWindow = (ScriptableObject)EditorMainWindow.FindContainerWindow(); winState.originalContainerWindow = winState.containerWindow; } if (fullscreenState.window == null) { fullscreenState.window = new List <WindowFullscreenState>(); } fullscreenState.window.Add(winState); return(winState); }
/// <summary> Toggle fullscreen for a window state, on the screen at position </summary> private static bool ToggleFullscreen(WindowFullscreenState windowState, bool createNewWindow, Vector2 atPosition) { if (windowState == null) { throw new NullReferenceException("windowState is null. Cannot continue."); } if (!loadedInitialState) { windowState.CloseOnExitFullscreen = createNewWindow; windowState.FullscreenAtPosition = atPosition; queuedStatesToToggleOnLoad.Add(windowState); if (LogNonFatalErrors) { throw new TypeLoadException("The fullscreen state hasn't been loaded yet. Fullscreen toggle has been queued."); } else { return(false); } } if (windowState.WindowType == mainWindowType) { return(EditorMainWindow.ToggleFullscreen(windowState.ShowTopToolbar, atPosition)); } if (windowState.EditorWin == null || (!windowState.IsFullscreen && createNewWindow)) { if (windowState.ActualType == typeof(SceneView)) { windowState.ActualType = typeof(CustomSceneView); } //Always create CustomSceneView for SceneView var win = EditorWindowExtensions.CreateWindow(windowState.ActualType); windowState.SetEditorWin(win); if (windowState.ActualType == typeof(CustomSceneView) || win.GetWindowType() == gameViewType) { win.SetWindowTitle(windowState.WindowName, true); //Reset title content on custom Scene and Game views to prevent icon not found error. } windowState.CloseOnExitFullscreen = true; //Since we are creating a new window, this window should close when fullscreen is exited bool setFullscreen = win.ToggleFullscreen(atPosition); return(setFullscreen); } else { return(windowState.EditorWin.ToggleFullscreen(atPosition)); } }