Example #1
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (eventData.button == PointerEventData.InputButton.Left)
        {
            //If a text link is clicked
            int linkIndex = TMP_TextUtilities.FindIntersectingLink(text, Input.mousePosition, null);
            if (linkIndex > -1)
            {
                var linkInfo = text.textInfo.linkInfo[linkIndex]; //Takes out the identifier of the link atribute
                var linkID   = linkInfo.GetLinkID().ToString();   //Gets the ID of the identified attribute


                Debug.Log(linkID);//Implement action here
                TextCommandManager.ExecuteCommand(linkID);
                linkInfo.textComponent = null;
                text.text = text.text.Remove(linkInfo.linkIdFirstCharacterIndex + linkID.Length + 1, linkInfo.linkTextLength);
                text.ForceMeshUpdate();
            }
        }
    }
Example #2
0
    public void OnCommand()
    {
        if (inputField.isFocused)
        {
            print("derp");
            command = inputField.text;

            bool success = TextCommandManager.ExecuteCommand(command);
            if (success)
            {
                text.text += "\n" + command;
            }
            else
            {
                text.text += "\n" + "Not a command";
            }

            inputField.text = "";
        }
    }