- Home /
Same size of a game object on every display
Hi,
I have been struggeling with this for a few days already. I am making a kinda vision test in Unity and need my GameObject (Image) to have the same size in cm on every screen, every resolution.
Anyone can give any input on how to achieve it?
Units like cm and inches and such aren't very useful because the graphics we're using are measured ultimately in pixels, and pixels can have different physical sizes (eg. iPhone 11 pixels are much smaller than GameBoy pixels) so to measure a centimeter in a PC screen you need that physical size of the pixels, then you can do a conversion, which means each screen will be vastly different. With that in $$anonymous$$d you should try to measure stuff in Unity units, especially because UI objects (like Image) are exactly suited for very flexible scaling for different resolutions. So yea, I would recommend you learn more about Unity UI and you'll probably get what you want :)
But sometimes one does need screen objects to be a fixed size regardless of screen resolution, and a vision test is clearly one of those times.
@unity_eUpT1lvqDGObtw You need to look at using Screen.dpi to work out the physical size of a pixel. Then you can set the image size (in pixels) to be the physical size that you want. It can get a little more complicated depending on the platform you're ai$$anonymous$$g at but that should point you in the right direction.
Hi! Could you find a solution for that? I have a similar problem now
See my comment above - you need to get hold of the DPI of the screen and use that to adjust sizes.
I didn't post a full answer due to not having time to do more than give a hint. I've converted your answer to a question, but if you get it working you could post an answer yourself. Answers are for answers to the original question on here, use comments for follow-up questions and nudges.
Your answer
![](https://koobas.hobune.stream/wayback/20220612214809im_/https://answers.unity.com/themes/thub/images/avi.jpg)