- Home /
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,
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();
}
Your answer
Follow this Question
Related Questions
Progress bar UI 2 Answers
Assigning UV Map to model at runtime 0 Answers
Shader: Mask Without a Texture? 2 Answers
Masking a plane object (which has an animated texture offset) 1 Answer
Adding Mask to Line Renderer 1 Answer