How to shrink a 2D game with the resolution (reposted)

Hi! I’m creating a 2D game and everything is working fine except one thing: changing the resolution. Whenever I change it, all it does is make the horizontal view smaller. There is no adjustment of GameObjects to fit the screen. When I run the game everything looks great, though this is because I’m building it in my resolution. What happens if a player adjusts the resolution to fit their screen? So basically what I’m asking is can you shrink your game with the resolution in code, and if so, how? I’ve literally searched everywhere for this, even here, and have’t found a single thing that works for me. I’ve posted this question before but it never got approved, and the “moderator” told me to just look it up and ask him if I still need help… which I did, yet he never responded. Thanks.

Also, my resolution is 1600:900 and I’m writing in C#

So you are saying if you change the resolution, game objects in the scene don’t fit in the view port? Do you mean on the sides of the view port? For example, changing the aspect ratio from 16:9 to say 4:3? If so, I would consider detecting this in script and adjusting the camera to fit the scene.

You can use values such as:

Camera.main.aspect // width / height
Camera.main.pixelWidth // number of pixels of width of camera
Camera.main.pixelHeight // number of pixels of height of camera

Resolution.width // screen resolution width
Resolution.height // screen resolution height