/// <summary> /// Exits the fullscreen game views. /// </summary> /// <param name="onlyThoseCreatedAtGameStart">If true, only exits the game views which were created when the game was started.</param> public static void ExitGameFullscreens(bool onlyThoseCreatedAtGameStart) { EditorFullscreenState.RunOnLoad methodToRun = ExitGameFullscreensAll; if (onlyThoseCreatedAtGameStart) { methodToRun = ExitGameFullscreensOnlyThoseCreatedAtGameStart; } if (EditorFullscreenState.RunAfterInitialStateLoaded(methodToRun)) { return; } var fullscreenGameWindows = new List <EditorWindow>(); foreach (var state in EditorFullscreenState.fullscreenState.window) { if (state.EditorWin != null && state.WindowType == EditorFullscreenState.GameViewType && state.EditorWin.IsFullscreen()) { if (!onlyThoseCreatedAtGameStart || state.CreatedAtGameStart) { fullscreenGameWindows.Add(state.EditorWin); } } } foreach (var gameWin in fullscreenGameWindows) { gameWin.SetFullscreen(false); } }
/// <summary> /// Toggles the top toolbar for the currently focused fullscreen window. (Only applies to Scene View, Game View, and Main Window, which have top toolbars). /// </summary> public static void ToggleTopToolbar() { if (EditorFullscreenState.RunAfterInitialStateLoaded(ToggleTopToolbar)) { return; } EditorFullscreenState.ToggleToolbarInFullscreen(); }
private static bool ToggleGameViewFullscreen(bool triggeredOnPlayStateChange) { EditorFullscreenSettings.FullscreenOption fullscreenOps; if (triggeredOnPlayStateChange) { fullscreenOps = EditorFullscreenSettings.settings.openFullscreenOnGameStart; } else { fullscreenOps = EditorFullscreenSettings.GetFullscreenOptionsForWindowType(EditorFullscreenState.gameViewType); } bool setFullscreen = !EditorFullscreenState.WindowTypeIsFullscreenAtOptionsSpecifiedPosition(EditorFullscreenState.gameViewType, fullscreenOps); EditorFullscreenState.RunOnLoad methodToRun; if (!triggeredOnPlayStateChange) { methodToRun = ToggleGameViewFullscreen; } else { methodToRun = ToggleGameViewFullscreenPlayStateWasChanged; } if (EditorFullscreenState.RunAfterInitialStateLoaded(methodToRun)) { return(setFullscreen); } setFullscreen = EditorFullscreenState.ToggleFullscreenAtOptionsSpecifiedPosition(null, EditorFullscreenState.gameViewType, fullscreenOps, triggeredOnPlayStateChange); var focusedWindow = EditorWindow.focusedWindow; EditorMainWindow.Focus(); if (focusedWindow != null) { focusedWindow.Focus(); } if (!triggeredOnPlayStateChange) { bool isPlaying = EditorApplication.isPlaying || EditorApplication.isPlayingOrWillChangePlaymode; if (settings.startGameWhenEnteringFullscreen && !isPlaying && setFullscreen) { //Enter play mode EditorApplication.ExecuteMenuItem("Edit/Play"); } else if (settings.stopGameWhenExitingFullscreen != EditorFullscreenSettings.StopGameWhenExitingFullscreen.Never && isPlaying && !setFullscreen) { if (settings.stopGameWhenExitingFullscreen == EditorFullscreenSettings.StopGameWhenExitingFullscreen.WhenAnyFullscreenGameViewIsExited || !WindowTypeIsFullscreen(EditorFullscreenState.gameViewType)) { //Exit play mode EditorApplication.ExecuteMenuItem("Edit/Play"); } } } return(setFullscreen); }
private static bool ToggleGameViewFullscreen(bool triggeredOnGameStart, int optionID) { EditorWindow focusedWindow = null; List <FullscreenOption> allGameWins = null; EditorFullscreenState.WindowFullscreenState state = null; bool setFullscreen; if (triggeredOnGameStart) { allGameWins = settings.AllGameWindows; setFullscreen = true; } else { setFullscreen = !EditorFullscreenState.WindowTypeIsFullscreenAtOptionsSpecifiedPosition(EditorFullscreenState.GameViewType, settings.GetFullscreenOption(optionID)); } EditorFullscreenState.RunOnLoad methodToRun; if (!triggeredOnGameStart) { methodToRun = () => ToggleGameViewFullscreen(false, optionID); } else { methodToRun = () => ToggleGameViewFullscreen(true, optionID); } if (EditorFullscreenState.RunAfterInitialStateLoaded(methodToRun)) { return(setFullscreen); } if (triggeredOnGameStart) { for (int i = 0; i < allGameWins.Count; i++) { if (allGameWins[i].openOnGameStart) { if (!EditorFullscreenState.WindowTypeIsFullscreenAtOptionsSpecifiedPosition(EditorFullscreenState.GameViewType, allGameWins[i])) { EditorFullscreenState.ToggleFullscreenUsingOptions(null, EditorFullscreenState.GameViewType, allGameWins[i], triggeredOnGameStart, false); } } } } else { state = EditorFullscreenState.ToggleFullscreenUsingOptions(null, EditorFullscreenState.GameViewType, settings.GetFullscreenOption(optionID), triggeredOnGameStart, false, out setFullscreen); focusedWindow = EditorWindow.focusedWindow; } EditorMainWindow.Focus(); if (focusedWindow != null) { focusedWindow.Focus(); } if (!triggeredOnGameStart) { bool isPlaying = EditorApplication.isPlaying || EditorApplication.isPlayingOrWillChangePlaymode; if (settings.startGameWhenEnteringFullscreen && !isPlaying && setFullscreen) { //Enter play mode EditorApplication.ExecuteMenuItem("Edit/Play"); } else if (settings.stopGameWhenExitingFullscreen != EditorFullscreenSettings.StopGameWhenExitingFullscreen.Never && isPlaying && !setFullscreen) { if (settings.stopGameWhenExitingFullscreen == EditorFullscreenSettings.StopGameWhenExitingFullscreen.WhenAnyFullscreenGameViewIsExited || !WindowTypeIsFullscreen(EditorFullscreenState.GameViewType, state)) { //Exit play mode EditorApplication.ExecuteMenuItem("Edit/Play"); } } } return(setFullscreen); }