# Change width and height of 2D object based on pixel size and count

I'm working on a shooting simulator with shooting goals that need to be in real world size. I know the certain size of screen display and pixel counts.

Is there anyway to change their size based on screen information?

let me explain more about question.

its a real shooter simulator with real guns. image of unity simulation is projected on a wall or... by a video projector. I want to scale goals as real ones. I know size of screen and even size of every pixel. so I want to scale my rectangular goals with size of real ones.

I think the question now is obvious

• The answer is also obvious, use them as the unit scale, scale everything else to match up. – Joshua Hedges Jun 6 '17 at 19:26

If you mean that they need to have static sizes regardless of screen size, you would need to calculate by resolution AND exact screen size (this is actually difficult, as you'd need a database of all possible screens this can run on).

So, for instance, 1cm x 1cm images are going to be different pixel sizes on an iPhone 4 and an iPhone 6 Plus, not to mention on a Galaxy S7.

iPhone4 = 960 x 640 resolution on a 7.4cm x 4.9cm screen = ~130px x 130px

iPhone 6 Plus = 1334 x 750 @ 12.2cm x 6.8cm = ~110px x 110px

Galaxy S7 = 2560 x 1440 @ 11cm x 7cm (roughly) = ~ 230px x 230px

Needless to say, this isn't an ideal scenario to try to pull off, which is why it's rare for games to use real-world sizes for things.

• I think you didn't understand the question. I will modify that – virtouso Jun 6 '17 at 19:07
• The answer is still similar, except now as to the size, it's a function of distance of the projector to the wall and the image size it can properly light. In this case, resolution is almost useless because the "real" size is solely however large you let your focal point get. – Jesse Williams Jun 6 '17 at 19:42
• For example, you could use an Epson projector, set the size and go with it. A user could use the exact same projector, but have it 0.5m further away from the wall and the displayed image will be x amount larger. For a demo, this can be handled if the user has the ability to manipulate the projector placement. In many instances, the projector and screen are fixed distances from one another and there would be no specific control over resulting size. – Jesse Williams Jun 6 '17 at 19:44