When making health bars, is there a specific reason that people don't just use cubes with textures set at a certain distance from the main camera?
Are the cubes more taxing then a GUI or do other people just find it easier to work with GUI? Because I've just found it easier to work with cubes on screen is all.
If you want this kind of health bar :
then yes, a cube or a plane is ok.
But as soon as you try to achieve non rectangular bars, such as this example, or even just non-rectangular bar (which is kind of a standard nowadays), you have to go with a sprite + mask
Yeah, that's pretty much what I figured, but after looking at the example you showed me, it seems like you'd be better off going with the alpha mask, even if it is a bit more effort, due to presentation. Hmmm, perhaps I shall have to look into it
How did you achieve the gas and nos bars in your monster truck game using planes, if you don't mind me asking
I have a second camera in my scene that is orthographic. Pointing at all my UI elements.
I then used his most esteemed Sir Michael Garforth's CreatePlane script from the wiki to create a bottom anchored plane. Thus when you scale it, it scales from the bottom, not the middle, so the bar resizes.. well like a progress bar.
For the planes I obviously don't use Unity's default plane, you can use the same script to create a 1x1 (two triangle plane mesh) for better performance.
Then just scale the plane height based on your value and a percentage of the plane at it's max height.
This setup works on all resolutions.. but if the screen aspect ratio changes, you'll need to do some manual adjustment of the plane positions. But other than that it will work on all resolutions and aspects/screen resizing you throw at it, which is another reason I preferred it to UnityGUI.
Last edited by Meltdown; 03-03-2012 at 11:56 AM.
Yeah I just use textured planes. Don't care much for Unity's GUI system.
Completely new to game development and Unity? don't know where to start? You don't have to be a n00b, click here and you'll be a pro in no time! The complete scripting series will bring you from zero to hero!
Really guys, get over it. Everyone these days wants a MMO not single player. I know we should start out small but times have changed. Anymore in the game industry no matter how small or large you have to go big or go home!