How to make Battery Bar?

Yeah i was wondering how would i make a bar so it shows up as a health bar but slowly decrease as time passes by. Any help would be appreciated.

Go here http://unity3d.com/support/documentation/Components/gui-Layout.html and scroll down to the example labeled “/* Using multiple Groups to clip the displayed Contents */”

var bgImage : Texture2D; // background image that is 256 x 32 (coud be a different size, but has to match the sizes below (GUI.BeginGroup (Rect (0,0,256,32));)
var fgImage : Texture2D; // foreground image that is 256 x 32
var duration = 1.0; //how long the healthbar will last
private var time : float;

function OnGUI () {
	//increase the amount of time each frame, clamp it so it doesn't go higher than duration
	time = Mathf.Clamp(time + Time.deltaTime, 0, duration)

	// Create one Group to contain both images
	// Adjust the first 2 coordinates to place it somewhere else on-screen
	//adjust the last 2 coordinates to change the size
	GUI.BeginGroup (Rect (0,0,256,32));

	// Draw the background image
	GUI.Box (Rect (0,0,256,32), bgImage);

	// Create a second Group which will be clipped
	// We want to clip the image and not scale it, which is why we need the second Group
	GUI.BeginGroup (Rect (0,0,(time-duration)/duration * 256, 32));

	// Draw the foreground image
	GUI.Box (Rect (0,0,256,32), fgImage);

	// End both Groups
	GUI.EndGroup ();
	GUI.EndGroup ();
}

Give that a try and tell me if you need more help.

minor change:

GUI.BeginGroup (Rect (0,0,(time-duration)/duration * 256, 32));