Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Unity game window aspect ratio doesn't match the build aspect ratio

Discussion in 'Editor & General Support' started by Pohlerbaer, Jun 14, 2022.

  1. Pohlerbaer

    Pohlerbaer

    Joined:
    Mar 8, 2022
    Posts:
    7
    Hey guys!

    I've been looking for an answer for this for quite a while now, but couldn't find anything that helped me.

    So what I'm trying to do, is to build my game in portrait format with a aspect ratio of 9:16 (4K Resolution). In my game window, the result looks like this: upload_2022-6-14_13-13-14.png

    weirdly, when I build the game in lower resolutions, everything in the UI fits perfectly, just like in the reference picture above.
    As soon as I try to build the game in the same resolution as specified above (Touchscreen), the UI doesn't fit anymore, and extends way further then in my game window. Here a snippet from the build:
    upload_2022-6-14_13-16-28.png

    Even more confusing to me is, that this also only works when I build in windowed mode. When I try to build a fullscreen application, it completely messes up the view, not even being portrait mode anymore, although the resolution is specifically set to: upload_2022-6-14_13-19-58.png

    Does anyone here have an idea if I overlooked something?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,533
    Width/Height won‘t exceed what your monitor allows. In windowed mode it is probably trying to retain the aspect ratio within the game window, but in fullscreen there‘s only a specific set of supported resolutions, and none of them will be 9:16 (more commonly: 16:9 or 5:4 or 4:3). Therefore you see more stretching in fullscreen mode.

    What platform are you developing for? I was assuming based on the aspect ratio that it is a mobile app. What does it look like on the target device?

    If it is for Windows, consider that there are very few monitors supporting 4096 resolutions. More common and also referred to as 4k is the 3840x2160 resolution. To use that resolution in Windows with a portrait app you‘d have to turn the monitor by 90 degrees and change the windows display setting to match the rotation. Only then can you use a 2160x3840 (or 2304x4096 if the monitor supports it) app in fullscreen/portrait mode. Of course this is only viable if you have control over the target hardware, such as for kiosk displays used for advertisement and such.

    And all of this works in the editor because you can freely specify the resolution (since the dev hardware is likely different from target hardware), Unity will scale the rendering accordingly (hence the scale factor slider).