I use the multiple images for mine, and I have about 180 images for (each) of my circles. This is how I did it:
First, I made the bars/circles whatnot in my 3d editor of choice, then animated the bars/circles so that it would appear that they filled up. I rendered the animation out as an image sequence so I would have an individual image for each amount.
Made a helper function to load a specified sequence of images into an array from the Resources folder, so that I didn’t have to click/drag each image into a slot on a texture array:
//loads a sequence of images from Resources folder. Expects images to be numbered from 0001 to (maximum) 9999.
//Returns the image sequence as an array
//filetype doesn't matter, as Resources.Load doesn't take a filetype (you leave it out of the the name)
public static function LoadSequence(namePrefix : String, length : int) : Array{
var bars = Array(length);
var i=0;
for (i=0;i<length;i++)
{
var j = i + 1;
if (j < 10){
//Debug.Log("loading " + namePrefix + "000" + j);
bars[i] = Resources.Load(namePrefix + "000" + j, Texture);
}
else if (j < 100){
//Debug.Log("loading " + namePrefix + "00" + j);
bars[i] = Resources.Load(namePrefix + "00" + j, Texture);
}
else if (j < 1000){
bars[i] = Resources.Load(namePrefix + "0" + j, Texture);
}
else{
bars[i] = Resources.Load(namePrefix + j, Texture);
}
}
return bars;
}
to use this, I have something like this (EGUI was the script the loader function was in):
private var quarterCircleValues = [];
function Awake() {
quarterCircleValues = EGUI.LoadSequence("quarterCircleValue_", 180);
}
As you can see, it loads a sequence of images named from quarterCircleValue_0001 to quarterCircleValue_0180 into an array.
Then, I access just the index of the array that I want to based upon the percentage of health/ammo/whatever remaning.
function OnGUI(){
var smallLeftIndex = Mathf.RoundToInt((quarterCircleValues.length-1)*weaponsController.HandLaserCharge());
GUI.DrawTexture(Rect (scrWdth - isi, mainpos.y - isi, isi, isi), quarterCircleValues[smallLeftIndex]);
}
It takes a second on starting a level to load all the textures into the array, but once it is done, it’s still quite fast. It looks great too, as it makes the circle smoothly increment/decrement. It is probable you could even speed this up by using a Texture[ ] instead of a general Array, but I’m unsure how to work with those currently.