Search Unity

Game Window Scale

Discussion in 'Editor & General Support' started by eatsleepindie, Jul 10, 2018.

  1. eatsleepindie

    eatsleepindie

    Joined:
    Aug 3, 2012
    Posts:
    355
    Am I missing something, or is there a reason I would want to have my game window forced to 1.25x when scaling up text on my UHD monitors? The build itself does not scale anything, why is the minimum of the Game window slider now 1.25x?

    I have never used this slider, ever. At least not intentionally. There are countless times that I wasn't sure why the contents of the Game window looked funky and that slider ended up being the culprit, likely because I moved the mouse wheel while hovered over the window accidentally. But now... now this slider is ruining my day.

    I can see making the default match my scaling settings - I can't justify it with any rational thought, but I could have at least just shrugged my shoulders and muttered "why?" before moving it where it belongs. But forcing it to 1.25x is absolutely pointless.
     
  2. eatsleepindie

    eatsleepindie

    Joined:
    Aug 3, 2012
    Posts:
    355
    My bad, it seems you can fix this by clicking the "Low resolution.." checkbox. Thing is, if you're using multiple screens, you have to look for the dropdown on the main monitor, not the monitor that the Game window is actually on. I can deal with the dropdown in the wrong place, so color me happy while I eat some crow.
     
  3. greenheartgames

    greenheartgames

    Joined:
    Jan 29, 2015
    Posts:
    15
    Thanks for sharing this. Pretty sure I'd have wasted half a day figuring this out otherwise.
     
    eatsleepindie likes this.
  4. scorp2007

    scorp2007

    Joined:
    Aug 17, 2014
    Posts:
    54
    Today I downloaded the version 2018.3 and the checkmark that is not shown above does not help me, each application launch it is put in 1.25x. >:-(((((((((

    I noticed that in one project this does not happen, and in another happens, madness.
     
    Last edited: Dec 19, 2018
    McGravity, fredii3 and Mrz355 like this.
  5. Erikoinen

    Erikoinen

    Joined:
    Nov 10, 2014
    Posts:
    68
    This happens for me every time I press Play. :| Super annoying.

    Any idea if this setting can be set via code? So I could force it to 1x on Play.
     
  6. fredii3

    fredii3

    Joined:
    Aug 23, 2018
    Posts:
    2
    Same problem here, I've been all over google trying to find a way to fix it, but so far I have to manually adjust the scale using the slider every time after I press play.
     
    fnst and McGravity like this.
  7. fredii3

    fredii3

    Joined:
    Aug 23, 2018
    Posts:
    2
    Just to add something new I found - if you change the resolution and check-uncheck the "Low Resolution Aspect Ratios" a few times and then restart Unity - it fixes it. For a while.. Then the bug comes back
     
    fnst likes this.
  8. Pixygon

    Pixygon

    Joined:
    May 9, 2013
    Posts:
    26
    When setting the game view resolution, use Aspect Ratio, instead of Fixed Resolution.
    Set it using the same values as you would when using Fixed.
     
  9. SniperED007

    SniperED007

    Joined:
    Sep 29, 2013
    Posts:
    345
    This is incredibly frustrating.
    For me I used to be able to solve this by killing the Unity Hub and restarting it and then relaunching my project from there. But that doesn't seem to work anymore with the latest 2018.3.4f1

    My setup is 2 monitors, 1 is 4K. Wondering if that doesn't have something to do with it?
    The issue happens on both monitors but they default to different Scales.
     
  10. egicoro

    egicoro

    Joined:
    Feb 5, 2019
    Posts:
    2
    Hello. I think I found the root of issue. In Windows setting in Display section, we can change the size of text, apps etc. upload_2019-2-26_17-9-20.png


    This parameter also change Game View Scale in Unity. I played with value of this function and Unity Scale have been change every time, when I set new value for Scale in Windows.

    But I haven't enough mind to fix it :(
     
    jeffersonjales and r35 like this.
  11. egicoro

    egicoro

    Joined:
    Feb 5, 2019
    Posts:
    2
    So, for further generation. I have some semi-solve for this annoying issue. It works for me.

    This bug is appear in editor when you choosed Android build. Change your build platform to PC&Mac, open Game View and add new resolution in orientation, that you need. I am developing Anroid game in horizontal orientation so I choosed 1920x1080. After activate play mode and stop it. Now change your build platform back to Android. And scale in Game view have to stop stuck on Windows scale value.

    One disadvantages: you will need do it every time, before start work in Unity.
     
    r35 likes this.
  12. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    199
    I'm on a mac with iOS target and it still happens(
     
  13. jsmits062

    jsmits062

    Joined:
    Jul 16, 2014
    Posts:
    5
    This fixed the problem for me... any custom resolutions that I have configured over time have always been "Fixed Resolution"... When i updated to 2018.3 I noticed the Game Window scaling adjusts everytime I hit play when selecting one of my custom fixed resolutions. I just created a new custom resolution with the same values but this time selected "Aspect Ratio" and the game window no longer attempts to scale relative to a fixed resolution everytime I hit play.
     
  14. Flexford

    Flexford

    Joined:
    Dec 8, 2016
    Posts:
    20
    Code (CSharp):
    1. using System;
    2. using System.Reflection;
    3. using UnityEditor;
    4. using UnityEngine;
    5. using Object = UnityEngine.Object;
    6.  
    7. [InitializeOnLoad]
    8. public static class FixGameViewScale
    9. {
    10.     static FixGameViewScale()
    11.     {
    12.         EditorApplication.playModeStateChanged += OnPlayStateChanged;
    13.         SetGameViewScale();
    14.     }
    15.  
    16.     private static void OnPlayStateChanged(PlayModeStateChange playModeStateChange)
    17.     {
    18.         SetGameViewScale();
    19.     }
    20.  
    21.     private static void SetGameViewScale()
    22.     {
    23.         Type gameViewType = GetGameViewType();
    24.         EditorWindow gameViewWindow = GetGameViewWindow(gameViewType);
    25.  
    26.         if (gameViewWindow == null)
    27.         {
    28.             return;
    29.         }
    30.  
    31.         var defScaleField = gameViewType.GetField("m_defaultScale", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
    32.  
    33.         //whatever scale you want when you click on play
    34.         float defaultScale = 0.1f;
    35.  
    36.         var areaField = gameViewType.GetField("m_ZoomArea", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
    37.         var areaObj = areaField.GetValue(gameViewWindow);
    38.  
    39.         var scaleField = areaObj.GetType().GetField("m_Scale", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
    40.         scaleField.SetValue(areaObj, new Vector2(defaultScale, defaultScale));
    41.     }
    42.  
    43.     private static Type GetGameViewType()
    44.     {
    45.         Assembly unityEditorAssembly = typeof(EditorWindow).Assembly;
    46.         Type gameViewType = unityEditorAssembly.GetType("UnityEditor.GameView");
    47.         return gameViewType;
    48.     }
    49.  
    50.     private static EditorWindow GetGameViewWindow(Type gameViewType)
    51.     {
    52.         Object[] obj = Resources.FindObjectsOfTypeAll(gameViewType);
    53.         if (obj.Length > 0)
    54.         {
    55.             return obj[0] as EditorWindow;
    56.         }
    57.         return null;
    58.     }
    59. }
     
    Last edited: Nov 21, 2022
    TotiVasilev, TeeArr, AGregori and 7 others like this.
  15. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    This is not the same thing though. Setting it to "resolution" gives a pixel perfect representation of your device. Invaluable for setting up things like mipmaps, anistropy and texture resolutions. This may not apply to pc/mac targets, depending on your game.
     
  16. howler123

    howler123

    Joined:
    May 7, 2017
    Posts:
    17
    Just created a screen in Aspect Ratio, not Fixed Resolution fixed it.
     
  17. okartgame

    okartgame

    Joined:
    Mar 23, 2015
    Posts:
    1
    upload_2019-5-23_12-45-55.png Me helped installing Type in Aspect Ratio
     
  18. firstuser

    firstuser

    Joined:
    May 5, 2016
    Posts:
    147
    Workaround is great but a real fix would be really nice.
     
  19. paulartcc

    paulartcc

    Joined:
    Nov 11, 2019
    Posts:
    5
    Unity 2019.1.6f1 bug is still there. It's absolutely annoying.
     
  20. TheGameLearner

    TheGameLearner

    Joined:
    Feb 10, 2018
    Posts:
    20
    Whenever I am on a new system or new code, I often search for @Flexford 's answer for the script.
    It should have fixed by now somewhere for all stable releases.
     
  21. Smams68

    Smams68

    Joined:
    May 28, 2023
    Posts:
    15
    yup.
     
  22. ErrorCommander

    ErrorCommander

    Joined:
    Jul 8, 2021
    Posts:
    1
    This problem have for Unity 2022.3.8f1, with select platform Android. For PC - all ok.
    I have the scale set to a value of 1.3.
    This happens even when using the "Aspect" resolution. It still doesn't fit in the area of my window, which is very annoying.
     
    Last edited: Sep 25, 2023
  23. CortiWins

    CortiWins

    Joined:
    Sep 24, 2018
    Posts:
    150
    @Flexford, it's been half a year since you've been in this forum, but just in case you ever happen to come back i want you to know how really helpful this script is to me and that i appreciate that you shared your work here.
     
  24. KrynosStudios

    KrynosStudios

    Joined:
    Dec 9, 2023
    Posts:
    2
    I have found a working workaround for this issue for anyone who has the same problem.

    1. Right click on the "Game" tab at the top of the screen
    2. Click "Close tab"
    3. Right click on an open tab and select "Add tab > Game"
    4. Change view from "Free aspect" to desired resolution
    5. Change scale to desired value and hit play

    Now the game will start at the proper scale every time.
     
    ozgurkara71 likes this.
  25. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,513
    For editor problems of all stripes, sometimes it helps to reset the Layout to Default in the top right then apply a more specific fix.

    d - Copy.png
     
    rasofiagames likes this.
  26. rasofiagames

    rasofiagames

    Joined:
    Jun 26, 2019
    Posts:
    1
    This was the fix we were looking for. Thank you kindly!
     
  27. copperLP

    copperLP

    Joined:
    May 18, 2017
    Posts:
    1
    Just right click the Game tab, close it, and re-open the game window, the problem will be fixed.