Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: BadgerFarmer on July 22, 2023, 07:19:16 AM
-
Hi,
I'm looking for a way to make specific words in a passage of text interactable. From what I understand, this would be possible in C# using <link="ID>word</link> and writing a script that references the ID. But since I don't know C#, is there a way of achieving the same or similar in Playmaker?
I want to create a system where you click and hold on certain highlighted words, and that makes a copy of the word appear (as a separate button or TMP object) that you can drag and drop into another part of the screen.
Thanks for any advice.
-
Apologies for the bump - I really can't find anything on this.
Is there no way to reference the rich text <link> tag in Playmaker to add functionality to individual words in a passage of text?
-
You can achieve this with TMPro.
"take the eyeglasses and <link="look"><b>look</b></link> around to find something, then step back and <link="quit"><b>quit</b></link>"
use this script on an TMPro object, then use some PlayMaker logic to read the ID with get property.
// from https://forum.unity.com/threads/clickable-link-within-a-text.910226/
// post #17 with some tweaks for the word, you can use get property on PM to get the clicked word...
using UnityEngine;
using TMPro;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
[RequireComponent(typeof(TMP_Text))]
public class LinkOpener : MonoBehaviour, IPointerClickHandler
{
private TMP_Text m_textMeshPro;
public Camera MyCamera;
public string LinkedWord;
void Start()
{
m_textMeshPro = GetComponent<TMP_Text>();
}
public void OnPointerClick(PointerEventData eventData)
{
int linkIndex = TMP_TextUtilities.FindIntersectingLink(m_textMeshPro, new Vector3(Mouse.current.position.x.ReadValue(), Mouse.current.position.y.ReadValue(), 0), MyCamera);
if (linkIndex != -1)
{
TMP_LinkInfo linkInfo = m_textMeshPro.textInfo.linkInfo[linkIndex];
//Application.OpenURL(linkInfo.GetLinkID());
//Debug.Log("word is: " + linkInfo);
Debug.Log(linkInfo.GetLinkID());
LinkedWord = linkInfo.GetLinkID();
}
}
}
-
Action for playmaker; use the action after a mouse down. event, and store your string.
-
Great. Thanks. I'll give it a try.