x


Mask a HP Bar

I'm trying to make an HP Bar and found 2 answers

here http://answers.unity3d.com/questions/7846/how-do-i-make-a-progress-bar.html

and here http://answers.unity3d.com/questions/15774/scalemodescaleandcrop-crop-direction.html

that helped me, but it's not exactly what I want because my texture is not a rectangle, it is a parallelogram, like this, alt text

So when I change the width of the BeginGroup, since it uses a rectangle, the texture border becomes vertical. Is there a way to mask the texture but keeping the border like a parallelogram?

This is the code I'm using (the variable redBarWidth is modiffied when the character receives damage or gains hp)

public void OnGUI()
{
    GUI.BeginGroup(new Rect(redBarX, redBarY, redBarWidth, redBar.height));
    GUI.DrawTexture(new Rect(0, 0, redBar.width, redBar.height), redBar, ScaleMode.StretchToFill);
    GUI.EndGroup();
}
more ▼

asked Dec 20 '11 at 11:24 PM

_AinSoph_ gravatar image

_AinSoph_
31 2 2 3

(comments are locked)
10|3000 characters needed characters left

0 answers: sort newest
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2192
x65
x32
x7

asked: Dec 20 '11 at 11:24 PM

Seen: 716 times

Last Updated: Dec 20 '11 at 11:24 PM