Estoy tratando de hacer que mi juego se vea en pantalla completa y he encontrado algunos scripts en línea para lograrlo. Desafortunadamente, no puedo ejecutarlos en la versión 2020 (o 2018+). ¿Hay algún método para habilitar la ventana del juego en pantalla completa durante el modo editor? Del siguiente script, obtengo un error de excepción en System.Object Res = GetMainGameView.Invoke (null, null); ¿La versión actual de Unity no es accesible para GetMainGameView?
using UnityEditor; using UnityEngine; namespace FullScreenPlayModes { [InitializeOnLoad] public class FullScreenPlayMode : Editor { //The size of the toolbar above the game view, excluding the OS border. private static int toolbarHeight = 22; static FullScreenPlayMode () { EditorApplication.playModeStateChanged -= PlayModeStateChanged; EditorApplication.playModeStateChanged += PlayModeStateChanged; } static void PlayModeStateChanged (PlayModeStateChange _playModeStateChange) { if (PlayerPrefs.GetInt ("PlayMode_FullScreen", 0) == 1) { // Get game editor window EditorApplication.ExecuteMenuItem ("Window/General/Game"); System.Type T = System.Type.GetType ("UnityEditor.GameView,UnityEditor"); System.Reflection.MethodInfo GetMainGameView = T.GetMethod ("GetMainGameView", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); System.Object Res = GetMainGameView.Invoke (null, null); EditorWindow gameView = (EditorWindow) Res; switch (_playModeStateChange) { case PlayModeStateChange.EnteredPlayMode: Rect newPos = new Rect (0, 0 - toolbarHeight, Screen.currentResolution.width, Screen.currentResolution.height + toolbarHeight); gameView.position = newPos; gameView.minSize = new Vector2 (Screen.currentResolution.width, Screen.currentResolution.height + toolbarHeight); gameView.maxSize = gameView.minSize; gameView.position = newPos; break; case PlayModeStateChange.EnteredEditMode: gameView.Close (); break; } } } [MenuItem ("Tools/Editor/Play Mode/Full Screen", false, 0)] public static void PlayModeFullScreen () { PlayerPrefs.SetInt ("PlayMode_FullScreen", 1); } [MenuItem ("Tools/Editor/Play Mode/Full Screen", true, 0)] public static bool PlayModeFullScreenValidate () { return PlayerPrefs.GetInt ("PlayMode_FullScreen", 0) == 0; } [MenuItem ("Tools/Editor/Play Mode/Window", false, 0)] public static void PlayModeWindow () { PlayerPrefs.SetInt ("PlayMode_FullScreen", 0); } [MenuItem ("Tools/Editor/Play Mode/Window", true, 0)] public static bool PlayModeWindowValidate () { return PlayerPrefs.GetInt ("PlayMode_FullScreen", 0) == 1; } } }La mayoría de la gente sugeriría usar "maximizar en el botón de reproducción", que no es lo que desea.
Sugeriría que si desea probar el aspecto de su juego en pantalla completa, solo cree y ejecute después de editar la configuración de compilación/configuración del jugador y haga que el juego esté en pantalla completa o incluso use alt + enter para ir a pantalla completa y probar Tu apariencia; tu aspecto.
Esto será mucho más fácil que usar secuencias de comandos en el juego solo para probar la pantalla completa en el editor A MENOS QUE desee ver la salida de la consola mientras está en pantalla completa. También hay un activo gratuito en la tienda, vea la consola en construcción.
https://assetstore.unity.com/packages/tools/gui/in-game-debug-console-68068