I have this GUI to graphically display a variable similar to the health in a game. The variable 'test' goes up and down during gameplay.
To show this I have the following onGUI ():
public GUISkin btnskin1;
public Texture2D emptyTex;
public Texture2D fullTex;
public Vector2 pos = new Vector2(20,40);
public Vector2 size = new Vector2(60,20);
void OnGUI()
{
float test;
GUI.skin = btnskin1;
if (LoadDiagram.diagramaCarga.TryGetValue (TimeManager.gametime, out test))
{
GUI.BeginGroup (new Rect (pos.x, pos.y, size.x, size.y));
GUI.Box (new Rect (0, 0, size.x, size.y), emptyTex);
//draw the filled-in part:
GUI.BeginGroup (new Rect (0, 0, size.x * test, size.y));
GUI.Box (new Rect (0, 0, size.x, size.y), fullTex);
GUI.EndGroup ();
GUI.EndGroup ();
}
}
In the game scene I attached the empty bar to the emptyTex texture, and the full bar to the fullTex texture. When I play the game, he bar is always full. I have not inserted the minimum and maximum of the variable test because I don't know where, but I guess that may be necessary.
Any hints?
test
value during gameplay? Is it changing or not? \$\endgroup\$size.x * (test/6.0f)
instead ofsize.x * test
\$\endgroup\$