Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

420
Visualizações
Full screen mode game view in editor

I am trying to make my game view full screen and I have found few scripts online in order to achieve this. Unfortunately I am not able to execute them in 2020 version (or 2018+). Is there a method to enable full screen game window during editor mode? From the below script, I get exception error at System.Object Res = GetMainGameView.Invoke (null, null); Is the current Unity version not accessible for the 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;
        }
    }
}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Most people would suggest use "maximize on play button" which is not you want.

I would suggest if you want to test the look of your game in full screen just build and run after you edit Build settings/Player settings and make the game there full screen or even let use to use alt+enter to go full screen and test your look.

This will be much easier than using in game scripts just to test full screen in editor UNLESS you want to see console output while in full screen. There is also a free asset in store see the console in build.

https://assetstore.unity.com/packages/tools/gui/in-game-debug-console-68068

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda