Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

How can I make full screen in unity editor's game screen?

Discussion in 'Editor & General Support' started by leegod, Sep 4, 2011.

  1. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,080
    currently I am making 1280 * 768 resolution game.

    But if I use 1366 * 768 laptops (mostly be this), and if I hit play button for testing in unity editor, game screen does not become full screen mode even if I press the right-above's full screen button.

    How can I see unity editor's game screen as a full screen?

    I really need this function.

    Checking the [Maximize on Play] does not work.
     
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,686
    milansosef and noahmilam like this.
  3. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,080
    I input one line to my code but still it does not work.

    Screen.SetResolution (1280, 768, true);

    I mean not standalone or webplayer, but unity editor itself's game screen. so that I can test frequently in full screen mode even at 1366 * 768 laptops.
     
  4. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    That's actually a good question, I've run into the same situation myself. I've got a dual screen system so I just grab the "Game" view window and drag it to the second monitor and stretch it to the size I want. You could probably write an editor script that would do the same thing. Otherwise, you'll have to build a stand alone and run it to view it at the fullscreen resolution. If there's another (better) way to do it I'm all ears. ;)
     
  5. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,080
    so how I can resize the game screen's border to very thin or just delete the border itself to make it looks like full screen.?
     
  6. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I don't know if that's possible. What I typically do is drag the game view window to a screen that is larger than the size I need and then manually drag the corners until it's roughly the size I need.
     
  7. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,080
    I am saying in the case of I am outside and I have only 1366 768 laptops.
     
  8. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Right, I understand your question. I don't know if that's possible to do with an editor script. You may be able to drag and stretch the window so it's contents fill the vertical height of the screen. If not, you may have to preview by building a stand alone. I don't know of any good / easy solution to the problem, that's why I said it was a good question. ;)
     
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,291
    You can't (maximize on play is the closest you can get), but it shouldn't make any difference. All you need is the aspect ratio, not the exact number of pixels. You're using a 3D engine, so that usually means the game should run in any resolution. Ideally you should make it run in any aspect ratio too.

    --Eric
     
    sean244 likes this.
  10. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    True, except on those projects which require a specific screen resolution to be supported, which is what I'm thinking the OP is asking about. Ideally in that particular situation you have the monitor that the project will be playing on for design and testing purposes.
     
  11. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,080
    Actually, I really want to do what you say. But I already wrote much gui as, GUI.Button(Rect(100, 100, 50, 50),,,,

    Then when I play and if I size down the screen, whole gui seems crashed and cutted out.

    So I searched about how to set this seems right at low resolution, not read whole answers, but I saw the method of matrix4x4.TRS.

    But this does not work at all.

    So I want to resize the GUI elements too when I play it at low resolution.

    So then is it enough to do like this? GUI.Button(Rect(Screen.width/2-50,,,,)

    So whole GUI's Rect's standard position must be The middle position of screen? (Screen.width/2, Screen.height/2)?
     
  12. DarkSlash

    DarkSlash

    Joined:
    Sep 30, 2011
    Posts:
    126
    Same problem. I build and run every single time I need to test something. Even on a i7 is a pain. May be the developers of Unity hears us prayers! :)
     
    Jaqal likes this.
  13. Warp-Lemon

    Warp-Lemon

    Joined:
    Dec 21, 2015
    Posts:
    2
    GabrielSants likes this.
  14. mnml_

    mnml_

    Joined:
    Jun 17, 2015
    Posts:
    44
    the script is nice but it always changed my 'standalone' resolution to 'free aspect' (+ it closes the game window too often) - here's my cleaned up version that behaves much nicer

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEngine;
    3. using System.Collections.Generic;
    4.  
    5. [InitializeOnLoad]
    6. public class FullscreenPlayMode : MonoBehaviour {
    7.    //The size of the toolbar above the game view, excluding the OS border.
    8.    private static int tabHeight = 22;
    9.  
    10.    private static Dictionary<string, Vector2> settings = new Dictionary<string, Vector2> {
    11.       {"mnml", new Vector2(1920,0)} // sharing your code? offsets go in here!
    12.    };
    13.  
    14.    static FullscreenPlayMode() {
    15.       if (settings.ContainsKey(System.Environment.UserName)) {
    16.          EditorApplication.playmodeStateChanged -= CheckPlayModeState;
    17.          EditorApplication.playmodeStateChanged += CheckPlayModeState;
    18.       }
    19.    }
    20.  
    21.    static void CheckPlayModeState() {
    22.       // looks strange, but works much better!
    23.       if (EditorApplication.isPlaying) {
    24.          if (EditorApplication.isPlayingOrWillChangePlaymode) {
    25.             FullScreenGameWindow();
    26.          } else {
    27.             CloseGameWindow();
    28.          }
    29.       }
    30.    }
    31.  
    32.    static EditorWindow GetMainGameView() {
    33.       EditorApplication.ExecuteMenuItem("Window/Game");
    34.       System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor");
    35.       System.Reflection.MethodInfo GetMainGameView = T.GetMethod("GetMainGameView", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
    36.       System.Object Res = GetMainGameView.Invoke(null, null);
    37.       return (EditorWindow)Res;
    38.    }
    39.  
    40.    static Rect orig;
    41.    static Vector2 min;
    42.    static Vector2 max;
    43.  
    44.    static void FullScreenGameWindow() {
    45.       EditorWindow gameView = GetMainGameView();
    46.  
    47.       Rect newPos = new Rect(0, 0 - tabHeight, Screen.currentResolution.width, Screen.currentResolution.height + tabHeight);
    48.       newPos.position = newPos.position + settings[System.Environment.UserName];
    49.       orig = gameView.position;
    50.       min = gameView.minSize;
    51.       max = gameView.maxSize;
    52.  
    53.       gameView.position = newPos;
    54.       gameView.minSize = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height + tabHeight);
    55.       gameView.maxSize = gameView.minSize;
    56.       gameView.position = newPos;
    57.  
    58.    }
    59.  
    60.    static void CloseGameWindow() {
    61.       EditorWindow gameView = GetMainGameView();
    62.  
    63.       gameView.position = orig;
    64.       gameView.minSize = min;
    65.       gameView.maxSize = max;
    66.       gameView.position = orig;
    67.    }
    68. }
     
    Psyco92, sirxeno and SugoiDev like this.
  15. M-Yankov

    M-Yankov

    Joined:
    Aug 4, 2017
    Posts:
    1
    For me it works like:
    Code (CSharp):
    1. Screen.SetResolution(1600, 800, true);
    Before start the scene, go to Game tab and toggle Maximize on play
    If you didn't see effect - try toggle Maximize on play several times.
     
  16. Garrett_orious

    Garrett_orious

    Joined:
    Nov 16, 2016
    Posts:
    3
    Hey @mnml_ , just thought I'd point out your delegate gave me a small error. It should be:


    Code (CSharp):
    1. static void CheckPlayModeState( PlayModeStateChange state )
    2. {
    3.     ...
    4. }
    I may be wrong, but it seems like it fixed it for me.
     
  17. poisonnuke

    poisonnuke

    Joined:
    Nov 22, 2016
    Posts:
    82
    the code of @mnml_ seems to work, but only a few times. After a couple of times starting the game preview, the windows disappears completly and Ive got some "Scene out of view-frustrum" errors. To resolve this, I need to remove the script, restart the Unity (or sometimes Windows) and then close and open the game preview window again.

    Any idea, whats causing this?
     
  18. mmortall

    mmortall

    Joined:
    Dec 28, 2010
    Posts:
    89
    I think my video could help you. You can change play mode screen to exactly your screen size without limiting the physical screen size. This is some undocumented stuff but it works for me.
     
  19. poisonnuke

    poisonnuke

    Joined:
    Nov 22, 2016
    Posts:
    82
    isnt this more or less the same like mnml did, only with screenshot capability added?

    And I need it for testing touchscreen-inputs. I have a dedicated touch-screen on which I test everything. And the inputs of the screen are not scaled down to the downscaled preview, so everything is misaligned during a preview (or I have to scale it up to 1x, but then the game-borders are hidden behind the preview-window-borders.
     
  20. mmortall

    mmortall

    Joined:
    Dec 28, 2010
    Posts:
    89
    yes, look like. I've not read the whole thread. sorry
     
  21. Just_Ga_dev

    Just_Ga_dev

    Joined:
    Jan 7, 2018
    Posts:
    1
    Click shift and space on your keyboard at thesame time
     
  22. poisonnuke

    poisonnuke

    Joined:
    Nov 22, 2016
    Posts:
    82
    and then what? Any circumstances for doing it? because nothing happens if I press these buttons in the game window
     
  23. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    632
    It seems that the script from reddit by 'u/digitalsalmon' and the Asset Store product based on the same concept Pixel Perfect Game Window does not work in Unity 2018.2. The window size snaps to a max width of 1906 px on my 1920x1080 screen. I've messed with all the relevant methods on UnityEditor.GameView through reflection that I could think of but it still keeps snapping to just a bit less than full screen. I wonder if this is a restriction for EditorWindow that UT decided to put in there for whatever reason.

    I can't believe an editor full screen solution was not implemented by UT long ago.

    Did anyone find alternative solutions?
     
    id0, Psyco92, NEVER-SETTLE and 4 others like this.
  24. tufeixp

    tufeixp

    Joined:
    Sep 6, 2015
    Posts:
    22
  25. IsouEU

    IsouEU

    Joined:
    Aug 4, 2018
    Posts:
    7
    Believe man, some retards don't know what the "fullscreen" means, I'm 2 day trying to run "3d Game Kit" and the only forking way I found is changing to open GL, cause my videocard is not compatible with derrectx11, now in trying make play mode fullscreen to be hable to "play" cause the kit is realy very heavy and my carddon't like rendered overlay. But I'm starting to think it will not be possible, cause the guys that made unity have nice video cards... and simple don't understand what I trying to do...


    Edited: I want to see the game without compile in my conditions
     
  26. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    632
  27. axmiku

    axmiku

    Joined:
    Jul 4, 2018
    Posts:
    2
    Any suggestions how to solve the problem in Unity 2018.2+ ? maximal possible resoultion is 1906x1047px for the GameView on the second Monitor. I don't even see the source of the problem.
     
  28. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    316
    Unfortunately Pixel Perfect has been deprecated... I guess due to this 2018 problem. Are there any solutions?
     
  29. psotresc52

    psotresc52

    Joined:
    Sep 25, 2018
    Posts:
    1
    I have been using the Spout library for Unity, it is set in the camera and is sent to Touchdesigner (with really good results) where I can use it full screen, but it does not work with touch or mouse input. I have been looking for a solution but I can not find it.
     
  30. blackhawk_001

    blackhawk_001

    Joined:
    Jan 25, 2019
    Posts:
    11
    can you explain briefly this solution? i never use touchdesigner. i hope you can help me
     
  31. HeadZerg

    HeadZerg

    Joined:
    Aug 15, 2014
    Posts:
    16

    Attached Files:

  32. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    632
  33. Sfahaan

    Sfahaan

    Joined:
    May 25, 2020
    Posts:
    2
    How can I upload my problem .
     
  34. Sfahaan

    Sfahaan

    Joined:
    May 25, 2020
    Posts:
    2
    Why I can't see full screen of my game when testing in game menu.
    When I got that play button my game's camera size reduces to very small scale.
    I can't even see my game property.

    Please reply
     
  35. tqthinh88

    tqthinh88

    Joined:
    Jun 30, 2020
    Posts:
    1
    Go to "Main Camera" resize the camera view (the white rectangle in image) -> make sure your Camera Preview contain all of your game screen.
     

    Attached Files:

  36. Darkenstein

    Darkenstein

    Joined:
    Oct 24, 2016
    Posts:
    4
    Modified version of this https://gist.github.com/fnuecke/d4275087cc7969257eae0f939fac3d2f solution.

    - fullscreen mode is automatic
    - temporarily adds a dummy view to each dock area to stop rendering the standard Game view, Scene view, Hierarchy, Inspector, etc. (huge performance boost)
    - WARNING: the fullscreen game view is created in the 3rd frame

    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using System.Reflection;
    4. using UnityEditor;
    5. using UnityEngine;
    6.  
    7. [InitializeOnLoad]
    8. public static class PlayModeFullscreen
    9. {
    10.     static PlayModeFullscreen()
    11.     {
    12.         EditorApplication.playModeStateChanged += PlayModeStateChanged;
    13.     }
    14.  
    15.     private static void PlayModeStateChanged(PlayModeStateChange playModeStateChange)
    16.     {
    17.         switch (playModeStateChange)
    18.         {
    19.             case PlayModeStateChange.EnteredPlayMode:
    20.                 new GameObject("PlayModeFullscreen", typeof(PlayModeFullscreenMonoBehaviour));
    21.                 break;
    22.         }
    23.     }
    24. }
    25.  
    26. public class PlayModeFullscreenMonoBehaviour : MonoBehaviour
    27. {
    28.     private List<EditorWindow> dummyViews;
    29.     private EditorWindow fullscreenGameView;
    30.  
    31.     private void Awake()
    32.     {
    33.         // Hide this game object
    34.         gameObject.hideFlags = HideFlags.HideInHierarchy;
    35.         GameObject.DontDestroyOnLoad(gameObject);
    36.     }
    37.  
    38.     private void Update()
    39.     {
    40.         if (Time.frameCount == 3)
    41.         {
    42.             // Create dummy views
    43.             dummyViews = new List<EditorWindow>();
    44.  
    45.             Type dockAreaType = Type.GetType("UnityEditor.DockArea,UnityEditor");
    46.             UnityEngine.Object[] dockAreas = Resources.FindObjectsOfTypeAll(dockAreaType);
    47.  
    48.             MethodInfo addTabMethod = dockAreaType.GetMethod("AddTab", new Type[] { typeof(EditorWindow), typeof(bool) });
    49.             foreach (UnityEngine.Object dockArea in dockAreas)
    50.             {
    51.                 EditorWindow dummyView = ScriptableObject.CreateInstance<EditorWindow>();
    52.                 dummyView.titleContent = new GUIContent("Dummy");
    53.                 dummyViews.Add(dummyView);
    54.  
    55.                 addTabMethod.Invoke(dockArea, new object[] { dummyView, true });
    56.             }
    57.  
    58.             // Create fullscreen game view
    59.             Type gameViewType = Type.GetType("UnityEditor.GameView,UnityEditor");
    60.             fullscreenGameView = (EditorWindow)ScriptableObject.CreateInstance(gameViewType);
    61.  
    62.             PropertyInfo showToolbarProperty = gameViewType.GetProperty("showToolbar", BindingFlags.NonPublic | BindingFlags.Instance);
    63.             showToolbarProperty.SetValue(fullscreenGameView, false);
    64.  
    65.             fullscreenGameView.ShowPopup();
    66.             fullscreenGameView.position = new Rect(new Vector2(0, 0), new Vector2(Screen.currentResolution.width, Screen.currentResolution.height));
    67.             fullscreenGameView.Focus();
    68.         }
    69.     }
    70.  
    71.     private void OnDestroy()
    72.     {
    73.         // Destroy fullscreen game view
    74.         fullscreenGameView.Close();
    75.         fullscreenGameView = null;
    76.  
    77.         // Destroy dummy views
    78.         foreach (EditorWindow dummyView in dummyViews)
    79.         {
    80.             dummyView.Close();
    81.         }
    82.         dummyViews.Clear();
    83.         dummyViews = null;
    84.     }
    85. }
     

    Attached Files:

    Last edited: Mar 23, 2021
unityunity