Search Unity

"Resizable Window" and odd heights

Discussion in 'Editor & General Support' started by KnuckleCracker, Aug 2, 2013.

  1. KnuckleCracker

    KnuckleCracker

    Joined:
    Dec 27, 2011
    Posts:
    81
    Forget for a moment that "resizable window" blows up your OSX version and focus only on good old Windows.

    Check that box in player settings and voila! Users can now drag size your game window. Happy days are here again. Well, almost. Since a user can now drag the window to any size they can drag the window to an odd window height. So? Well if you have an orthographic camera then you need to set the orthographic size to half the window height, which of course isn't an integer value.

    Long story short, you can get yourself some rendering issues when you try to do some pixel perfect kind of things. I won't belabor them here, but rips, overlap, bleed... those sort of things. (Here's one reference for how this creeps into things: http://forum.unity3d.com/threads/49...awing/page98?p=1301366&viewfull=1#post1301366 )

    So, what to do? One thing might be to just prevent odd heights. So call Screen.SetResolution and make the height even whenever it actually ends up odd during a resize. Fixes the problem, but Screen.SetResolution also moves the window. So resize by dragging the window and end on an even height and everything is cool. Land on an odd height and the window jumps to the center of the screen.

    I see no other way to address this problem, other than to ignore that oh so tempting "resizable window" checkbox. Am I wrong?
     
  2. Graham-Dunnett

    Graham-Dunnett

    Administrator

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    Render to a even-sized render texture, and then render that minus one edge to the odd-sized window?

    Provide a settings menu where a user can choose different sized windows, perhaps with a slider for width and height, but where you deal with odd sizes by rounding up or down?
     
  3. KnuckleCracker

    KnuckleCracker

    Joined:
    Dec 27, 2011
    Posts:
    81
    Yeah, I have that settings window since that is currently the only option on OSX. And for most of my development I have ignored that 'resize window' checkbox. I didn't even notice it till 4.2 (granted I waited over a year to upgrade to Unity 4.1 hoping for greater stability).

    It's just so tempting to actually allow that window to be resized by dragging the frame. So many of my players play in a window, and being able to resize that window is just so nice... If SetResolution didn't move the window to the center of the screen, I could solve the problem. If there was a way to get and set the window position, I could solve the problem. So, so close.

    Render texture.. hmmm. I've got two camera's and a bunch of other junk involving camera positions, 'zoom', etc. I guess that could work, but I don't know what that would do to performance in my already 'on the performance edge' game. Thanks for the suggestion, though... I'd not thought of that one.

    Presently, I'm fiddling with a whole bunch of subpixel nudging in an attempt to work around the problem. Problem is it depends on the camera position and on the 'zoom' (factor of orthographic size)... and of course the old 'half pixel offset for directx' is thrown in the mix.