using System.Collections; using UnityEngine; using UnityEngine.UI; using TMPro; /// /// This class sets the text and image of the popup message /// public class PopupMessage : MonoBehaviour { public TextMeshProUGUI popupMessage; private Image image; /// /// Gets the X mark image in the child object /// private void Awake() { image = GetComponentsInChildren()[1]; } /// /// Sets the new test and shows or hides the X mark image. /// Hides the whole gameObject after 2 seconds /// /// /// /// public IEnumerator Reset(string newText, bool enabled = false) { popupMessage.text = newText; image.gameObject.SetActive(enabled); yield return new WaitForSeconds(2f); gameObject.SetActive(false); } }