Search Unity

Keep Aspect Ratio Of Scene When Resizing Game's Window?

Discussion in 'Scripting' started by JeZxLee, Jul 17, 2019.

  1. JeZxLee

    JeZxLee

    Joined:
    Jul 24, 2016
    Posts:
    222
    Hi,

    Been Googling for hours and can't see a solution to the below issue:
    How to keep aspect ratio of scene when resizing game's windows on standalone player & WebGL?
    (game's default screen size is: 360 x 640)

    Any ideas?
    Thanks!

    Jesse
     
  2. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    You mean when you allow the player to use the OS-level drag-to-resize-window functionality? I'm not sure if it's possible to control the window's aspect ratio when doing that, but you could always letterbox your content within the available window.

    If you are changing the size of the window yourself from code, then obviously you can enforce any constraint you want with some appropriate math.
     
  3. JeZxLee

    JeZxLee

    Joined:
    Jul 24, 2016
    Posts:
    222
    I asked question wrong...
    I mean how do I scale the game's window to keep aspect ratio after a window resize?
    Let me know, thanks!

    Jesse
     
  4. JeZxLee

    JeZxLee

    Joined:
    Jul 24, 2016
    Posts:
    222
    If I maximize the game's window, the Frames Per Second text is not located properly?
    See screenshot below:

    Jesse

    UnityWindowResize-01.png
     
  5. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    Well, how are you scaling the rest of your content, and what are you doing differently with your FPS text?
     
  6. JeZxLee

    JeZxLee

    Joined:
    Jul 24, 2016
    Posts:
    222
    this is fixed. Was the "Anchor Preset" - setting to center fix it, thanks!