- Home /
Making a progress bar a different color (Java)
I have a stamina and a health bar and I would like them to be different colors so that they can be distinguished easier. Here is my code for the stamina bar:
function OnGUI()
{
//Stamina
GUI.BeginGroup (new Rect (pos.x, pos.y, size.x, size.y));
GUI.Box (Rect (0,0, size.x, size.y),progressBarEmpty);
// draw the filled-in part:
GUI.BeginGroup (new Rect (0, 0, size.x * staminaBarDisplay, size.y));
GUI.Box (Rect (0,0, size.x, size.y), progressBarFull);
GUI.EndGroup ();
GUI.EndGroup ();
}
Any solution would be greatly appreciated!
Are progressBarEmpty and progresBarfull Texture2D/images or something? Have you tried duplicate this grouping change the locations and referencing an image of different color.
Yes, they are Texture2D. I am using the progressBarEmpty to hold text that I made in Photoshop. If I put a texture in one, it only shows up as a small version of the texture and I cant tile it.
Wherever you have this Texture2D in your project, click on it and in Inspector see that TextureType is set to GUI. If it only shows up small, you better check your size.x and size.y