using TMPro; namespace UnityEngine.XR.Interaction.Toolkit.Samples.StarterAssets { /// /// Add this component to a GameObject and call the method /// in response to a Unity Event to update a text display to count up with each event. /// public class IncrementUIText : MonoBehaviour { [SerializeField] [Tooltip("The TextMeshProUGUI component this behavior uses to display the incremented value.")] TextMeshProUGUI m_Text; /// /// The TextMeshProUGUI component this behavior uses to display the incremented value. /// public TextMeshProUGUI text { get => m_Text; set => m_Text = value; } int m_Count; /// /// See . /// protected void Awake() { if (m_Text == null) Debug.LogWarning("Missing required TextMeshProUGUI component reference. Use the Inspector window to assign which TMP component to increment.", this); } /// /// Increment the string message of the TextMeshProUGUI component. /// public void IncrementText() { m_Count += 1; if (m_Text != null) m_Text.text = m_Count.ToString(); } } }