First Commit
This commit is contained in:
1 parent
080f5fce79
commit
4c54d2f4b9
614 files changed
+53607
-19641
No files matched your search
+45
@@ -0,0 +1,45 @@
|
||||
using TMPro;
|
||||
|
||||
namespace UnityEngine.XR.Interaction.Toolkit.Samples.StarterAssets
|
||||
{
|
||||
/// <summary>
|
||||
/// Add this component to a GameObject and call the <see cref="IncrementText"/> method
|
||||
/// in response to a Unity Event to update a text display to count up with each event.
|
||||
/// </summary>
|
||||
public class IncrementUIText : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
[Tooltip("The TextMeshProUGUI component this behavior uses to display the incremented value.")]
|
||||
TextMeshProUGUI m_Text;
|
||||
|
||||
/// <summary>
|
||||
/// The TextMeshProUGUI component this behavior uses to display the incremented value.
|
||||
/// </summary>
|
||||
public TextMeshProUGUI text
|
||||
{
|
||||
get => m_Text;
|
||||
set => m_Text = value;
|
||||
}
|
||||
|
||||
int m_Count;
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="MonoBehaviour"/>.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increment the string message of the TextMeshProUGUI component.
|
||||
/// </summary>
|
||||
public void IncrementText()
|
||||
{
|
||||
m_Count += 1;
|
||||
if (m_Text != null)
|
||||
m_Text.text = m_Count.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user