progress bar

i am trying to create a health bar using draw texture it is working fine for me but the by using draw texture the texture itself is moving from its original position and how to increase the health bar from bottom to upward direction(- y direction).I want my texture should gradually increase from its original position to the clamped value with out moving the texture from its original position.Is any other method is there for health bar other than draw texture or how to use draw texture properly to get the result i want.

i have tried the code used in above link for making a health bar it is working fine for me. The using above code the texture itself is moving from its original position i want the health bar should increase gradually from its original position. i want to increase health bar in (- y direction).in above code if i am fixing the texture position to
var pos : Vector2 = new Vector2(20,40);

the whole texture starts move upwards.can you please fix this error in my coding as i am new to coding

I don’t think you want to use DrawTexture(). You would be better off having an alpha-cutoff plane in the center of your screen and then lerp the alpha cutoff parameter as the time passes so that the entire progress bar is visible.

var endTime : float = 10;
// time is just one possible way you could lerp.  Player position is another.  Or score
function Update () {
       var lerpParameter : float = 1 - Mathf.InverseLerp(0 , endTime , Time.time);
       //returns the lerp parameter between 2 values.
       renderer.material.SetFloat( "_Cutoff" , lerpParameter );

The setup for this isn’t too hard. Your progress bar needs to have a gradient alpha channel that fades from white to black (or black to white depending on which way you look at it :wink: ). Then as time goes on, progressively more of the texture will be visible and you will have a progress bar.