scrollbar

code:

var health = 50;

function OnGUI () {
GUI.HorizontalScrollbar (Rect (25, 25, 50, 10), 0, 10, health, 10);
}

i want the bar to start at the left and be longer if health is higher but i forgot what numbers to put where

That’s an interesting “misuse” of this function - it’s intended to control something, not to show a value - but yes, it can be used as a progress bar:

var health: float = 50;
var maxHealth: float = 100;
var dummy: float = 0; // "sticks" the button at the left

function OnGUI () {
  GUI.HorizontalScrollbar (Rect (25, 25, 120, 20), dummy, health, 0, maxHealth);
}

You must never allow the health to be lower than zero or greater than maxHealth, or the bar will grow to the wrong side (to the left). Another problem is that the bar never reaches zero length, even with zero health (and negative health will make it grow to the left, as mentioned above).