Screen resolution & mesh / 3D model scaling

HI all,

quick question on screen resoultion and best practices. If i change screen res using Screen.SetResolution() the UI scales as expected, but 3D models / meshes don’t. I’ve been googling all afternoon but can’t find how to handle this.

My inital thoughts were to have a script attached to anything that needs to scale (terrain, NPCS, player model, physics etc) and using DPI, and screen res apply a modifier that will basically increase the “assets” on display whilst maintaining the “1 unit measurement” for everything but i don’t think this is the correct way to handle it.

So basically, as the res increases from 1080 to 4K , as the ui gets smaller, i’d expect the assets to do the same, essentailly increasing what’s displayed on screen.

Apologies in advance for any confusing terminology, I’m new to Uiity & game dev.

thanks in advanced.

1 Like

Hi,

Welcome to our community! :slight_smile:

Game objects exist in the game scene. They do not scale up or down just because the resolution gets changed. The UI gets smaller because of the pixel density. Pixels are the lights in your monitor. If the sprite takes up 100 pixels, and 100 pixels (lights) take up 1 cm of space on your non-4k screen but 0.5 cm on your 4k screen, your sprite is 1 cm wide on your non-4k screen and 0.5 cm wide on your 4k screen.

When you change the resolution, the camera is not affected. The height is fixed, and the width depends on the aspect ratio. The picture the camera renders will look the same on all monitors with the same aspect ratio because the camera and non-UI elements do not depend on pixels.


See also:

1 Like

thanks for your quick reply! much appreciated. Ok so, I think I’ve finally just twigged lol orthographic camera is different to perspective. “Screen space” is aspect ratio based NOT resolution - I was expecting thigns to get smaller with increasing resolution :rofl: :upside_down_face: :shushing_face:

really quite embarrasing how much time I’ve wasted on this! :rofl: eulers / quatrenions no problems, matrix transforms, custom mesh / uv mappign no issues at all - but screen resolution i just couldn’t get my head around for what ever reason.

thanks Nina, you’ve saved me many more hours lol

1 Like

You are not wrong. While the pixel size remains the same, the UI elements appear smaller compared to the screen. For example, a 100 x 100 px sprite looks larger on a 200 x 200 px screen than on a 2000 x 2000 px screen.

It’s actually a good thing that you “wasted” some time on this subject because that’s the best way to learn. These concepts are not general laws of nature. Humans invented them. It might be that these things work completely different in another game engine.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms