I’ve created a Prefab called EquipmentSlot that has a TextMeshProUGUI and an EquipmentSlot script. The TextMeshProUGUI has no text by default. The script is:
public class EquipmentSlot : MonoBehaviour
{
TextMeshProUGUI _text;
Image _icon;
private void Start()
{
_text = GameObject.Find("Label").GetComponent<TextMeshProUGUI>();
_icon = GameObject.Find("Icon").GetComponent<Image>();
_text.text = "Empty";
}
}
I put 3 of these in my scene, with no overrides, and when I run my game I expect the text in each slot to change from being blank to “Empty”. However, this only happens on the first slot, and the others remain unchanged. I put breakpoints in my code and verified that the code is hitting the _text.text = “Empty” line every time, but for some reason the text isn’t changing.