How to make a gui for ammo count?

How do I make a GUI that displays bullets like “lllllllllll / 60”? Do I make like 30 different GUIs? What is the most efficient way of doing this? Thanks

You could just use the wrapping feature built into open gl and change the uv and size of the mesh each time, but that would require you to use something like EZGUI/write your own sprite class (which to be fair isn’t ludicrously hard). Ie:

UpdateBullets(int bulletCount) {
    SetSpriteUV(new Rect(0, 0, bulletCount, 1);
    SetSpriteSize(bulletCount, 1);
}

The disadvantage is that you can’t use an atlas, and will get one draw call, but it seems cheaper than other solutions.

Or, if text is sufficient, use the String constructor:

text = new String("|", bulletCount);

It might be an idea to only update this when it changes though to limit how many strings you throw at the GC. (I deliberately didn’t combine with the “/ 60” because you’ll probably want to separate them so the justification is easier)

Have a look at this page

It is a GUI text. You can attach a script to your player for example, and access the GUI text and update the text.

Use :

myCounterOfBullets--;
GameObject.Find("my_text_object").GetComponent("GUIText").text = myCounter.ToString() + " / 60";

This has to be called every time your player fires one bullet.