// Creates a piece of text void CreateContentView(string text, Transform parent) { TextMeshProUGUI storyText = Instantiate(textPrefab) as TextMeshProUGUI; storyText.text = text; storyText.transform.SetParent(parent, false); // Find the text link listener and listen to it TMP_LinkWatcher lnkWtcher = storyText.gameObject.GetComponent <TMP_LinkWatcher> (); lnkWtcher.linkClickedEvent.AddListener((arg) => linkClickedEvent.Invoke(arg)); }
// Creates a piece of text void CreateContentView(string text, Transform parent) { TextMeshProUGUI storyText = FindExistingText(text); if (storyText == null) { storyText = Instantiate(textPrefab) as TextMeshProUGUI; storyText.text = text; storyText.transform.SetParent(parent, false); // Find the text link listener and listen to it } ; TMP_LinkWatcher linkWatcher = storyText.gameObject.GetComponent <TMP_LinkWatcher> (); if (linkWatcher != null) { linkWatcher.linkClickedEvent.RemoveAllListeners(); linkWatcher.linkClickedEvent.AddListener((arg) => linkClickedEvent.Invoke(arg)); } ; }