From 8263edd59284aba390aca011d25b79efecef4c48 Mon Sep 17 00:00:00 2001 From: pryazha Date: Wed, 2 Jul 2025 08:46:23 -0700 Subject: init --- .../DemoSceneAssets/Scripts/IncrementUIText.cs | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Assets/Samples/XR Interaction Toolkit/3.1.2/Starter Assets/DemoSceneAssets/Scripts/IncrementUIText.cs (limited to 'Assets/Samples/XR Interaction Toolkit/3.1.2/Starter Assets/DemoSceneAssets/Scripts/IncrementUIText.cs') diff --git a/Assets/Samples/XR Interaction Toolkit/3.1.2/Starter Assets/DemoSceneAssets/Scripts/IncrementUIText.cs b/Assets/Samples/XR Interaction Toolkit/3.1.2/Starter Assets/DemoSceneAssets/Scripts/IncrementUIText.cs new file mode 100644 index 0000000..9f72261 --- /dev/null +++ b/Assets/Samples/XR Interaction Toolkit/3.1.2/Starter Assets/DemoSceneAssets/Scripts/IncrementUIText.cs @@ -0,0 +1,45 @@ +using UnityEngine.UI; + +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 Text component this behavior uses to display the incremented value.")] + Text m_Text; + + /// + /// The Text component this behavior uses to display the incremented value. + /// + public Text text + { + get => m_Text; + set => m_Text = value; + } + + int m_Count; + + /// + /// See . + /// + protected void Awake() + { + if (m_Text == null) + Debug.LogWarning("Missing required Text component reference. Use the Inspector window to assign which Text component to increment.", this); + } + + /// + /// Increment the string message of the Text component. + /// + public void IncrementText() + { + m_Count += 1; + if (m_Text != null) + m_Text.text = m_Count.ToString(); + } + } +} -- cgit v1.2.3-70-g09d2