Ctrl + Space maximizes most windows in unity 2018 when in edit mode. Is there a keyboard shortcut to maximize the Game window when you're playing your game?
Can't find anything in the docs.
Ctrl + Space maximizes most windows in unity 2018 when in edit mode. Is there a keyboard shortcut to maximize the Game window when you're playing your game?
Can't find anything in the docs.
You can implement it yourself.
void Update()
{
#if UNITY_EDITOR
if (Input.GetKeyDown(KeyCode.Escape))
{
UnityEditor.EditorWindow.focusedWindow.maximized = !UnityEditor.EditorWindow.focusedWindow.maximized;
}
#endif
}
I think you are able to maximize the windows if it's docked, for floating Windows it shall not work. but you can try (Shift + Space) or Alt + Enter.
Hope it helps you and have a nice day.
Created a script to do the job that doesn't need to be attached to a gameobject:
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
static class FullscreenShortcut
{
static FullscreenShortcut()
{
EditorApplication.update += Update;
}
static void Update()
{
#if UNITY_EDITOR
if (EditorApplication.isPlaying && ShouldToggleMaximize())
{
EditorWindow.focusedWindow.maximized = !EditorWindow.focusedWindow.maximized;
}
#endif
}
private static bool ShouldToggleMaximize()
{
return Input.GetKey(KeyCode.Space) && Input.GetKey(KeyCode.LeftShift);
}
}
A little simpler than Update
static class FullscreenShortcut
{
#if UNITY_EDITOR
[UnityEditor.MenuItem("Window/MaximizeCurrentWindow _F11")]
static void ToggleCurrentWindowMaximized()
{
var window = UnityEditor.EditorWindow.focusedWindow;
if (window == null)
return;
window.maximized = !window.maximized;
}
#endif
}
there is a little more info about MenuItem: https://hugecalf-studios.github.io/unity-lessons/lessons/editor/menuitem/
just add at the end of MenuItem text
Symbol | Keyboard Key |
---|---|
% | Ctrl/Command |
# | Shift |
& | Alt |
_ | None |
with
Special Key | Keyboard Key |
---|---|
A-Z | Letters A-Z |
LEFT, RIGHT, UP, DOWN | Arrow Keys |
F1-F12 | F1-F12 |
HOME | Home |
END | End |
PGUP | Page Up |
PGDN | Page Down |
Click this button on the game scene "Maximize On Play" once and you never need to do use short keys again because it repeats itself until you turn it off. IF you still need it on urgent basis you can simply click on the screen and use the (Shift + Space) because it is used to maximize any window you are currently working on whether it game screen or any Hierarchy portion.
Based on the answer of @Ethan Fischer I created the following script which utilizes the new Input System and adds an extra condition.
In playmode the editor still accepts SHIFT+SPACE input for all editor windows except for the game view. This script uses Reflection to get the type of the GameView and compares it to the currently focused window (I observed weird behavior without this check)
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class MaximizeWhilePlaymode {
#if UNITY_EDITOR
private static InputEditor input;
private static float shift;
static MaximizeWhilePlaymode() {
input = new InputEditor();
input.Editor.Enable();
input.Editor.LeftShift.performed += ctx => shift = ctx.ReadValue<float>();
input.Editor.Space.performed += ctx => Work(ctx.ReadValue<float>());
}
private static void Work(float space) {
if(Application.isPlaying && shift > 0.5f && space > 0.5f) {
Assembly assembly = typeof(EditorWindow).Assembly;
Type type = assembly.GetType("UnityEditor.GameView");
if(EditorWindow.focusedWindow.GetType() == type) {
EditorWindow.focusedWindow.maximized = !EditorWindow.focusedWindow.maximized;
}
}
}
#endif
}
If the game is already built, try pressing Alt + Enter.
Not a shortcut, but you can switch Max/Normal size while in game mode when you click on the tiny menu button on top right corner (then toggle the Maximize option).