- Home /
Stats bars help
What I'm trying to accomplish here is drawing 10 stat bar pieces (using HP as an example)in a row in a list/array. If I were doing this in XNA, this would be no problem but seeing as how I am using Unity I can't seem to find anything on doing this.
All I have so far for this are the stats (all ints) and the bar back and content textures. I'm not asking you to write the code for me, I'm just asking for a little assistance. Thank you!
For an example of what I'm trying to do (as an image I made in SAI... The red pieces are what I'm trying to draw)
Answer by Griffo · Apr 12, 2014 at 08:51 AM
How I do it is I have an array of 11 textures, 1 blank the 10 others, increasing 1 at a time all the way up to 10
var clipsLeft : Texture2D[];
So i have 10 in the array from 1, increasing 1 at a time.
Then I use a variable, clipCount , from 100 to 0 and when it drops by 10 I swap to the next in the array.
GUI.DrawTexture(Rect(10, 74, clipGrfxX, clipGrfxY), clipsLeft[clipCount], ScaleMode.StretchToFill, true, 0);
You could do it the same way with your health, swapping the texture to a lower one each time the player looses 10 percent of health.
Your answer
![](https://koobas.hobune.stream/wayback/20220613142530im_/https://answers.unity.com/themes/thub/images/avi.jpg)