diff options
| author | dereelatwit <54997325+dereelatwit@users.noreply.github.com> | 2023-08-03 14:05:08 -0400 |
|---|---|---|
| committer | dereelatwit <54997325+dereelatwit@users.noreply.github.com> | 2023-08-03 14:05:08 -0400 |
| commit | b8aa2e0935f309b112648f0352f35f5f33da946b (patch) | |
| tree | 9121ae1a65e483dddba8367cbbdd4991abfb3e26 /Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_TextEventCheck.cs | |
| parent | 374125ba34e0366afb062578906877cfdf229bb9 (diff) | |
started implementing UI
Diffstat (limited to 'Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_TextEventCheck.cs')
| -rw-r--r-- | Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_TextEventCheck.cs | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_TextEventCheck.cs b/Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_TextEventCheck.cs new file mode 100644 index 0000000..abbe658 --- /dev/null +++ b/Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_TextEventCheck.cs @@ -0,0 +1,73 @@ +using UnityEngine; + + +namespace TMPro.Examples +{ + public class TMP_TextEventCheck : MonoBehaviour + { + + public TMP_TextEventHandler TextEventHandler; + + private TMP_Text m_TextComponent; + + void OnEnable() + { + if (TextEventHandler != null) + { + // Get a reference to the text component + m_TextComponent = TextEventHandler.GetComponent<TMP_Text>(); + + TextEventHandler.onCharacterSelection.AddListener(OnCharacterSelection); + TextEventHandler.onSpriteSelection.AddListener(OnSpriteSelection); + TextEventHandler.onWordSelection.AddListener(OnWordSelection); + TextEventHandler.onLineSelection.AddListener(OnLineSelection); + TextEventHandler.onLinkSelection.AddListener(OnLinkSelection); + } + } + + + void OnDisable() + { + if (TextEventHandler != null) + { + TextEventHandler.onCharacterSelection.RemoveListener(OnCharacterSelection); + TextEventHandler.onSpriteSelection.RemoveListener(OnSpriteSelection); + TextEventHandler.onWordSelection.RemoveListener(OnWordSelection); + TextEventHandler.onLineSelection.RemoveListener(OnLineSelection); + TextEventHandler.onLinkSelection.RemoveListener(OnLinkSelection); + } + } + + + void OnCharacterSelection(char c, int index) + { + Debug.Log("Character [" + c + "] at Index: " + index + " has been selected."); + } + + void OnSpriteSelection(char c, int index) + { + Debug.Log("Sprite [" + c + "] at Index: " + index + " has been selected."); + } + + void OnWordSelection(string word, int firstCharacterIndex, int length) + { + Debug.Log("Word [" + word + "] with first character index of " + firstCharacterIndex + " and length of " + length + " has been selected."); + } + + void OnLineSelection(string lineText, int firstCharacterIndex, int length) + { + Debug.Log("Line [" + lineText + "] with first character index of " + firstCharacterIndex + " and length of " + length + " has been selected."); + } + + void OnLinkSelection(string linkID, string linkText, int linkIndex) + { + if (m_TextComponent != null) + { + TMP_LinkInfo linkInfo = m_TextComponent.textInfo.linkInfo[linkIndex]; + } + + Debug.Log("Link Index: " + linkIndex + " with ID [" + linkID + "] and Text \"" + linkText + "\" has been selected."); + } + + } +} |
