I made a script for a lifebar, and it kinda works, except for the fact that it won't change when lifes are lost..
Here's my script:
var itemTracker;
itemTracker = GameObject.FindWithTag("GameController").GetComponent(GameStats);
var positionFromTop = 10;
var positionFromLeft = 10;
var textureWidth = 100;
var textureHeight = 50;
var lifeBarTexture;
var hundredPercentLife : Texture ;
var ninetyPercentLife : Texture ;
var eightyPercentLife : Texture ;
var seventyPercentLife : Texture ;
var sixtyPercentLife : Texture ;
var fiftyPercentLife : Texture ;
var fourtyPercentLife : Texture ;
var thirtyPercentLife : Texture ;
var twentyPercentLife : Texture ;
var tenPercentLife : Texture ;
function Update()
{
if(itemTracker.playerLife > 90)
lifeBarTexture = hundredPercentLife;
if(itemTracker.playerLife > 80 && itemTracker.playerLife < 91)
lifeBarTexture = hundredPercentLife;
if(itemTracker.playerLife > 70 && itemTracker.playerLife < 81)
lifeBarTexture = hundredPercentLife;
if(itemTracker.playerLife > 60 && itemTracker.playerLife < 71)
lifeBarTexture = hundredPercentLife;
if(itemTracker.playerLife > 50 && itemTracker.playerLife < 61)
lifeBarTexture = hundredPercentLife;
if(itemTracker.playerLife > 40 && itemTracker.playerLife < 51)
lifeBarTexture = hundredPercentLife;
if(itemTracker.playerLife > 30 && itemTracker.playerLife < 41)
lifeBarTexture = hundredPercentLife;
if(itemTracker.playerLife > 20 && itemTracker.playerLife < 31)
lifeBarTexture = hundredPercentLife;
if(itemTracker.playerLife > 10 && itemTracker.playerLife < 21)
lifeBarTexture = hundredPercentLife;
if(itemTracker.playerLife > 0 && itemTracker.playerLife < 11)
lifeBarTexture = hundredPercentLife;
}
function OnGUI()
{
GUI.Box(Rect(positionFromLeft, positionFromTop, textureWidth, textureHeight), lifeBarTexture);
}