Hello everybody … Can someone help me make this bar to be loaded from the bottom up.
because I can only do it to be loaded from top to bottom.
using UnityEngine;
using System.Collections;
public class PowerBar: MonoBehaviour {
public float barDisplay ;
public Vector2 pos = new Vector2(20,40);
public Vector2 size = new Vector2(60,20);
public Texture2D emptyTex;
public Texture2D fullTex;
public float speeDisplay=0.0f;
public bool DirectionUp;
public GUIStyle style;
public static float outPower;
void OnGUI() {
GUI.BeginGroup(new Rect(pos.x, pos.y, size.x, size.y));
GUI.Box(new Rect(1,0, size.x, size.y), emptyTex,style);
GUI.BeginGroup(new Rect(0,0, size.x , size.y* barDisplay));
GUI.Box(new Rect(1,0, size.x, size.y), fullTex,style);
GUI.EndGroup();
GUI.EndGroup();
}
void Update() {
if(barDisplay<=0)
DirectionUp= true;
if(barDisplay>=1)
DirectionUp=false;
if(DirectionUp)
{
barDisplay += Time.deltaTime*speeDisplay;
}else{
barDisplay -= Time.deltaTime*speeDisplay;
}
if(barDisplay>0)
outPower = barDisplay*1000;
print(outPower);
}
}