- Home /
How to retain absolute gameobject size in pixels no matter the resolution?
Is there a way to scale a 3d Game Object to a specific pixel width and height regardless of what resolution is set?
I'm using the alpha cut-off health bar method as seen in this thread and need to be able to set absolute scale for the objects being used as the meters. No matter what I try I can't get them to scale correctly.
I'm using an orthographic camera for them if that helps any.
Answer by jonas-echterhoff · Jun 16, 2010 at 01:38 PM
What do you need to draw? For 3d geometry (ie Meshes), you typically don't wont to set the size in pixels. But if you do, you can always divide the scale by some factor of Screen.width and Screen.height.
For 2d GUI stuff, you can use a GUITexture (set pixel size using the pixelInset Rect) or GUIText (set pixelCorrect flag).
What needs to scale are two health meters. They have to be 3d gameobjects because they use a material, so they can't be GUI objects (which can't use materials). See the thread I linked to if you need info. I'm just going to write a setup that scales according to the screen width and height, but I was hoping there was some quick way to do it that was already built in.
Answer by TowerOfBricks · Dec 02, 2010 at 07:00 AM
What about using a GUITexture? I think they can use materials, might be wrong here though.