Unity Scaling Entire Game Build to different aspect ratios (Not canvas scaler?)

I have a game which I have designed for the 16:9 aspect ratio of my computer. This results in other computers being able to see less or more than a 16:9 ratio screen because of this ratio. I tried to load my build onto a computer with a 16:10 aspect ratio, and edges of the screen were cut off, meaning things that happened near the edge of the screen could not be seen, including the player during certain interactions. I would want the resolution to always show more space on a bigger screen, but never cut anything off. Some people to do this have used canvas scalers - which work - but only for the canvas, obviously. Some people have changed the resolution player settings, but the options to set screen resolution are only available for windowed.
How would I make it so a bigger screen can see more, any screen never has any parts cut off but also never any black bars?

As you intuit, 3D is gonna be different than 2D is gonna be different than Canvas UI.

To keep important stuff in sight, I would just reach for Cinemachine.

Here are the official docs on how to make your UI handle various resolutions and aspect ratios cleanly:

Here are some notes on UI Anchoring, Scaling, CanvasScaler, etc:

Usually you need to choose a suitable ScaleMode and MatchMode in the Canvas Scaler and stick with it 100%. Generally if you change those settings you will often need to redo your UI entirely.

Here’s some more fit-inside-UI-content notes:

https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/HOWTO-UIFitContentSize.html

I also use this CanvasScalerOrientationDriver utility to make sharing UI for Landscape / Portrait easier. Read what it does carefully.

I’m confused by this because I keep seeing mentions of canvas scaler, but my understanding is that this only scales the canvas, as the name would suggest.
If I had a game in which there was no canvas, how could I scale this correctly.
Disregarding my original post, how could I make it so my game is built for 16:9 and scales according to resolution such that any larger aspect ratio has proportionately sized black bars on the side it is longer?
I have a canvas scaler component which does this correctly in terms of the canvas, but how could I make it so that the game in itself is set to this aspect ratio? I tried getting this to work but as I mentioned originally setting a default resolution is only available in windowed mode.

Ortho cameras base viewed area of the world on .orthographicSize property.

Perspective cameras base views on .fieldOfView property.

If you really have critical stuff that MUST remain in frame, seriously, this problem has been solved… look to Cinemachine, or else you must engineer a solution yourself.

I figured it out, I had the “default is native resolution” setting on, which turned off lets me change a default resolution to values of my choice, which results in black bars covering parts of the screen for bigger aspect ratios. Another thing I had to do to get this to work was delete the

  • Screenmanager Resolution Height
  • Screenmanager Resolution Width
  • Screenmanager Is Fullscreen mode
    keys from the windows registry because it saves a resolution that may not be the correct one.
1 Like