- Home /
Why does my UI.text only update when I change weapons?
Hey, I've created a game where you can pick up weapons and they have an ammo count. With that I made a Text gameobject so the player can see how many bullet he has. However this text will only display a correct ammount if I pick up a weapon, then another and change from the latest to the first i picked up. The weapons get attached and disattached to the player gameobject accordingly. Any help is much appreciated. thanks.
public int AllBullets;
public int currentBulletsInClip;
void Start()
{
ammoUI.text = currentBulletsInClip.ToString() + "/" + AllBullets;
}
void Update ()
{
//ammo UI
ammoUI.text = currentBulletsInClip.ToString() + "/" + AllBullets;
}
$$anonymous$$aybe can you share the script where you are changing your currentBulletsInClip?
What you have should work as long as any changes to either bullet variable are in update.
Answer by Suave · Jul 27, 2017 at 03:39 PM
I fixed it. I assinged those 2 ints to 2 other ints in another script and attached it to the text.UI it self (gameobject)
Your answer
![](https://koobas.hobune.stream/wayback/20220612131246im_/https://answers.unity.com/themes/thub/images/avi.jpg)