Keep Aspect Ratio like in Unity Editor

Basically what I want to achieve is keeping my game in a 16:9 Aspect Ratio, even in Windowed mode when scaling it around. In Unity Editor it works when I just select 16:9 Ratio but in Build it won’t work. That’s how I want it to work in Build:

As u can See in the Pictures it always keeps a 16:9 Ratio. Once the Dark-Grey Bars are left and right (First Picture) and once they are over and under (Second Picture). How can I achieve this in Build? Thanks in advance. ~ Julian

Did you checked the UI scale mode of your Canvas Scaler component? Or have you correctly set the ratio you want to in the player settings?

You can achieve this by changing Viewport Rect property of Camera but you’ll need to calculate it yourself based on desired and current screen aspect ratio.