Search Unity

Game View Zoom toggle or options

Discussion in 'Editor & General Support' started by Pix10, Jul 28, 2016.

  1. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    850
    Can we please have options for setting what the slider represents (I.e 1:1 fit to selected resolution preset rather than simply scaling to view height), or an option to disable the feature, as we can with other view features.

    I understand why this feature exists, but it's completely counter-productive for those who *don't* need it, or need the game view in 1:1 for I.e. Pixel perfect art layout or screen capture, or just generally find it intrusive.
     
  2. shawn

    shawn

    Unity Technologies

    Joined:
    Aug 4, 2007
    Posts:
    552
    Before adding preferences/toggles, I'd like to understand better how the functionality is getting in your way. We iterated on this behavior with both 2D & 3D developers/designers. Ideally we make the functionality be smart and not get in your way when it makes sense, instead of you having to toggle the behavior yourself.
     
  3. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    850
    Hi Shawn,

    It gets in the way because it overrides the size of the maximized Game window, where I need a 1:1 pixel game window for many reasons, in particular specific long-established workflows and tools.

    The slider value itself is less than intuitive. I initially thought it was using view window height, but it seems maybe it's the desktop Height?

    i.e. Set the Game view resolution to 1920x1080p on a 1440p monitor and the slider to 1x. Where are the corners? What's happened to the aspect ratio? (The 1080 camera is now taller than the Game View). Is this intentional or a bug? (see first attached image)

    There's no documentation that I can find other than:

    "zoom out to see the entire screen where the device resolution is higher than the Game View window size"

    So on paper this is a logical feature to have, except it doesn't appropriately account for resolutions that are smaller than the Game View window size: The slider's Min value is locked if if the device resolution is lower than the Game View, as shown in the second image.

    I'd have expected that the ideal value for a zoom slider would be a relative to the device resolution. This is how art packages have worked since the dawn of computer graphics.

    But today at least I would settle for being able to render the Game view in 1:1 again!

    Cheers

    GameViewSlider_1x_Means_What.jpg
    GameViewSlider_BrokenWorkflows.jpg
     
    Last edited: Jul 29, 2016
  4. shawn

    shawn

    Unity Technologies

    Joined:
    Aug 4, 2007
    Posts:
    552
    Hm... this actually looks wrong. 1x slider should be 1:1 like you want. I'm curious, are you using any scaling in your OS display settings? Your entire editor UI looks a bit blurry, which makes me think that your OS is rendering Unity at smaller dimensions and then scaling it up to fit your 1440p OS resolution.
     
  5. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    524
    @shawn Slightly related to this but not a bug, after finally getting retina resolution support on OSX in Unity 5.4 the editor has become almost unusable on my MacBook Pro. The scene and game views are being rendered at high resolution so performance is really bad. I was hoping the zoomer might help but it doesn't quite manage, so after finding this thread in the beta forums (http://forum.unity3d.com/threads/retina-gameview-too-slow-on-macbook-pro.392429/) I've disabled retina support for the Unity app.

    The thread also suggests using a fixed resolution for the game view but I usually have it set to 'Free Aspect' so it takes up whatever space it has with other palettes being moved around all the time. The current zoom feature obviously zooms the game view but that doesn't affect the screen dimensions for the game, it just zooms everything in. Setting a fixed resolution at half the size I have and then zooming 2x almost works but has to use scroll bars pretty quickly when space runs out and obviously needs the fixed resolution to be updated whenever other palettes are resized.

    Unlikely, but is there a way to support retina in the editor but only when needed in the scene and game views by having an option to pixel-double/scale so it doesn't have to render at the native high resolutions?
     
  6. shawn

    shawn

    Unity Technologies

    Joined:
    Aug 4, 2007
    Posts:
    552
    @greg-harding we've been talking about adding the ability to select "Free Aspect" but half resolution for the gameview. Largely this is to keep the "Free Aspect" behavior, but UI elements will still be same size as before retina support, but this will help your case as well.

    SceneView is a bit more problematic, but we're aware of performance hits on older machines and larger projects and have some ideas going forward.
     
  7. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    524
    @shawn sounds great :) I doubt at the moment if it's only old machines, rather it's high-end laptops with high dpi displays being driven by mobile gpus. Over time no doubt it will improve as hardware gets better but at the moment it's unusable for us. I guess a feature like this would also help low/mid-range desktop machines driving new 4k+ displays etc. as they become more popular and affordable.

    Also, while you're reading, the Unity 5.4.0f3 Editor on OSX constantly asks for firewall permission when opening even after the app has been whitelisted/allowed in the settings.
     
    Last edited: Aug 1, 2016
  8. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    850
    Oh boy. The ultimate in facepalms! Display Settings > 125% text scaling.

    Problem fixed, thank you for spotting that, I hadn't even noticed and probably never would have.

    Of course, now everything is tiny...but there's also more of it :)
     
  9. shawn

    shawn

    Unity Technologies

    Joined:
    Aug 4, 2007
    Posts:
    552
    We deliberately did development of the retina functionality on a retina macbook (not MacBook Pro), to get the worst case scenario. I suspect that this is highly project dependent. Anyways, it's on our radar!

    Could you report a bug please? I don't know of any other bug reports for this (there could be one, but nothing has come up in front of me yet).
     
  10. shawn

    shawn

    Unity Technologies

    Joined:
    Aug 4, 2007
    Posts:
    552
    Yeah, content scaling is on our todo list. So you can get nice pixel-perfect scaling of editor UI content, regardless of OS scaling. The work for macOS retina and game view resize has been the first steps in that direction.
     
    Pix10 likes this.
  11. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    524
    Sure, done. #819351

    Update: was reproduced by QA.
     
    Last edited: Aug 2, 2016
  12. jonc113

    jonc113

    Joined:
    Mar 10, 2013
    Posts:
    22
    I find myself accidentally moving the scale slider, so being able to disable it would be nice. If the change is small, it sometimes seems like I've mis-scaled my object - then I realize - oh it's that %$#@ slider again. The first time it happened it took me a while to figure out what was wrong, as I was unaware of this feature...
     
  13. shawn

    shawn

    Unity Technologies

    Joined:
    Aug 4, 2007
    Posts:
    552
    Interesting. First we'll look into making it harder to accidentally click, rather than disabling it, but it's good to know that misclicks like this happen here.
     
  14. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
    Hi!

    I second that. Game view scale is very unproductive. For some reasons it tends to just jump to 2x at random times when play is starting. And it messes up a scaled UI. I would very very much like to disable view scale.
     
    JohnnyFactor and fpage like this.
  15. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    230
    I am also experiencing the issue of the Game View scale constantly jumping to 2x. It would be very nice if there was a way to toggle that zoom feature off entirely.
     
  16. Phusckidus

    Phusckidus

    Joined:
    May 6, 2013
    Posts:
    8
    Even though I like the function I would also prefer a way of disabling it. Since it is changed by using the scroll wheel, i have more than once "scaled by accident"
     
  17. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    Ditto. Every few minuets or when i click Play in the Editor XD In out, in out, Closing/reopening/shutting down does not fix. Will keep an eye out for Unity update as it seems common problem and most likely fixed already :)
    However i like the feature and would prefer a fix and not it being changed.

    Edit: Macbook Pro Retina 2016 - Not touching touchpad and it still happens.
     
  18. JayArgh

    JayArgh

    Joined:
    Jul 23, 2013
    Posts:
    9
    I too am experiencing the frequent jumping and defaulting to 2x, the cause of which I can't determine - it's quite inconvenient!

    FWIW, I'm on a new MacBook Pro.
     
    jesusluvsyooh likes this.
  19. nbaris

    nbaris

    Joined:
    Jan 13, 2015
    Posts:
    27
    It always jumps to 2x for me too, making only the center parts of the game visible. So I have to set it back to 1x every single time I hit play.
     
    jesusluvsyooh likes this.
  20. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    Times I scroll = 100,000
    Times I want to zoom in to a pixelated Game view = 1
    Times i have to check if I accidentally again got zoomed in a bit = 99,999
    ----
    And speaking of:
    Times I switch Scene: 99
    Times I Switch Project: 1
    However..
    [Menu] Open Scene: Horrible UX of throwing me out in OS to dig out Scenes
    [Menu] Open Project: Nice view of recent Projects
    ----
    Maybe it's because:
    If you develop games this is how it is, but if you develop Unity all of the above numbers are opposite..?
     
    fben, JohnnyFactor and Schneider21 like this.
  21. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    Gotta throw my own two cents in on this as well. The Game view scale jumping to 2x seemingly randomly (but definitely each time on project load) is very irritating. MacBook Pro (15" retina) mid 2014, here.
     
  22. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824


    Was there any solution to this? It's slowly driving me crazy having to adjust the zoom back to 1x every few minutes.
    Is there a way to just switch off the zoom feature altogether?
     
    Last edited: Aug 19, 2017
  23. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    +1 & bump & upvote!!
     
    Mishaps and petey like this.
  24. Mishaps

    Mishaps

    Joined:
    Nov 28, 2011
    Posts:
    181
    Anyone found a solution to this random jump to 2x scale? Drives me nuts too. Macbook Pro touchbar. Wish this feature could be disabled.
     
  25. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824
    I was thinking even an editor script that just constantly put it back to 1x would be fine, but I haven’t figured out a way to do that. :(
    It’s annoying since it’s a feature I think only 2d people will ever use.
     
  26. Mishaps

    Mishaps

    Joined:
    Nov 28, 2011
    Posts:
    181
  27. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824
    Hehe yeah, this is still a super annoying bug. I have to change it so often that I sorta don’t notice it though :D
    I’m pretty sure I’ve seen it in the newer (17.) versions of unity too sadly.
     
  28. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    Year later and still have the bug. :eek:
    It was narrowed down to Touchpads and possibly macbooks right?
     
  29. Mishaps

    Mishaps

    Joined:
    Nov 28, 2011
    Posts:
    181
    sounds about right. Happens right after serialisation finishes (while iterating code etc). Not always tho. Give user sense of "happening often and randomly" which adds to the frustration.
     
  30. Mishaps

    Mishaps

    Joined:
    Nov 28, 2011
    Posts:
    181
    Personally, I have no use for the game view zoom function. Even just some editor API access would be enough of a solution we could write a script or something to always zoom back to 1x. GAH!
     
  31. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824
    Yeah, I never even use this feature so it's super annoying to have to deal with it :mad:
    Decided to try and get a script happening, but I know very little about this stuff so it might not work.

    I haven't really tested it, I'll try and see how I go.
    If anyone else wants to try it out, put this script into an editor folder in the project.

    Code (CSharp):
    1. using System.Reflection;
    2. using UnityEditor;
    3. using UnityEngine;
    4. using UnityEditor.Callbacks;
    5.  
    6. public class StopZoomingFFS
    7. {
    8.     [PostProcessSceneAttribute(2)]
    9.     public static void OnPostprocessScene()
    10.     {
    11.         SetSize();
    12.     }
    13.  
    14.     public static void SetSize()
    15.     {
    16.         float targetScale = 1;
    17.         var gvWndType = typeof(Editor).Assembly.GetType("UnityEditor.GameView");
    18.         var gvWnd = EditorWindow.GetWindow(gvWndType);
    19.         var areaField = gvWndType.GetField("m_ZoomArea", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
    20.         var areaObj = areaField.GetValue(gvWnd);
    21.         var scaleField = areaObj.GetType().GetField("m_Scale", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
    22.         scaleField.SetValue(areaObj, new Vector2(targetScale, targetScale));
    23.     }
    24. }
    I found a bunch of things from these posts -
    https://answers.unity.com/questions/956123/add-and-select-game-view-resolution.html
    https://forum.unity.com/threads/control-the-new-game-view-scale-slider-via-script.435385/
    (and thanks to Zod Bain from discord :) for the heads up on the callback!)

    Pete.
     
  32. Grumpy-Dot

    Grumpy-Dot

    Joined:
    Feb 29, 2016
    Posts:
    93
    That is simple. I have not tested this on a Mac, but let me know if you have issues.

    Code (CSharp):
    1. using System;
    2. using System.Reflection;
    3. using UnityEditor;
    4.  
    5. [InitializeOnLoad]
    6. public class SetScaleGameView
    7. {
    8.     static SetScaleGameView()
    9.     {
    10.         EditorApplication.update += SetGameViewScale;
    11.     }
    12.  
    13.     private static void SetGameViewScale()
    14.     {
    15.         Type T = Type.GetType("UnityEditor.GameView,UnityEditor");
    16.         UnityEngine.Object[] objectsOfTypeAll = UnityEngine.Resources.FindObjectsOfTypeAll(T);
    17.         EditorWindow gameview = objectsOfTypeAll.Length <= 0 ? null : (EditorWindow)objectsOfTypeAll[0];
    18.         if (T != null && gameview != null)
    19.         {
    20.             MethodInfo snapZoomMethod = T.GetMethod("SnapZoom", BindingFlags.Instance | BindingFlags.NonPublic);
    21.             PropertyInfo minScaleProperty = T.GetProperty("minScale", BindingFlags.Instance | BindingFlags.NonPublic);
    22.             if (minScaleProperty != null && snapZoomMethod != null)
    23.             {
    24.                 float minScale = (float)minScaleProperty.GetValue(gameview, null);
    25.                 snapZoomMethod.Invoke(gameview, new object[] { minScale });
    26.             }
    27.         }
    28.     }
    29. }
    Reflection to the rescue!
     
    Last edited: Mar 7, 2018
    Gerard_Slee likes this.
  33. Grumpy-Dot

    Grumpy-Dot

    Joined:
    Feb 29, 2016
    Posts:
    93
    I missed your reply :) please check the code from mine and let me know if you have any feedback.
     
  34. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824
    Hehe, no worries, thanks for taking a look!
    I haven't had a chance to check it, most of that stuff is a mystery to me (it's all weird undocumented stuff) but I've had my script running for a few days and I think it's working :D !
     
    Grumpy-Dot likes this.
  35. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    The Unity Staff obviously don't use MacBooks :D
    I'l try the scripts, thanks!

    StopZoomingFFS.cs

    just noticed that! Nice! :p

    Added both scripts, did a quick test to try get zoom bug to happen and it hasnt, which of the two scripts would you recommend ?
     
    Last edited: Mar 10, 2018
  36. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824
    Well I haven’t tried grumpy’s yet but it gets called at a different time to mine. Mine gets called after pressing play which’s is cool most of the time but the problem would sometimes occur for me when Im working on layout and switching back and for from vscode and unity. It would be nice if I could trigger the callback from unity gaining focus or something.
    But yeah, I guess no one has a MacBook at Unity3d
     
  37. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    I'm coming back here-- again-- to throw my pointless vote in. It happens every time I press play or compile a script and it's been happening for ages. This is on Mac OS but not a macbook. iMac 2017. This bug is already in the issue tracker but it was closed and abandoned years ago. Issue 779699.

    On the upside, I found an unorthodox way to (temporarily) fix it: Force-quit Unity and reload. If Unity happens to crash, it will happen again, but you can Force-quit and it should be back to normal again. My guess is there's a flag that gets set when quitting and starting Unity and when it doesn't shut down gracefully, it doesn't get set. This is not a 100% fix, just something that usually works for me.
     
    Starryyen715 and deekpyro like this.