Access text object found in start() in another class function
I have created a class that I am calling from inside a non-MonoBehaviour and need to be able to edit text objects with. Finding the text object can only be done in start but obviously I am only running start once and am running my other functions a lot more. The problem is that due to the scope of timerText it cannot find a definition of timerText and I can't find it anywhere else. I don't know if there is a way to make timerText global or if there is a better way to find and change game objects in newly created classes but any help would be great thank you!
public class MyMono : MonoBehaviour
{
public Text timerText;
void Start()
{
timerText = GameObject.Find("Timer").GetComponent<UnityEngine.UI.Text>();
}
public void UpdateUI(string message)
{
Debug.Log("Received " + message);
timerText.text = message;
}
}
Comment