M
M
Mimocodil2022-04-06 03:23:45
Unity
Mimocodil, 2022-04-06 03:23:45

How to make links in dialogues like in TES Morrowind?

In dialogues with NPCs, you can specify a topic, after which the character will write his answer. In his answer, some words, phrases and phrases are highlighted in blue. If you click on such highlighted places, then the character will give out his cue.

Question such - how to make such function?

The thought that comes to my mind in this regard is to create a layer on top of the dialog with scrolling transparent buttons, synchronized with the text and its scrolling in such a way that it is always above the right places. Before I killed a few days on this, I would like to know if there is a simpler solution or even a ready-made tool?

Examples:
0IvymH5o.png
0IBmZe97.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GFX Data, 2022-04-06
@Ezekiel4

You can use the standard TextMeshPro package.
The text is marked with a markup with the link tag:

Link <link=56><color=#FF88FF><b>example</b></color></link> text.

And somewhere on the stage we hook our component script:
public TextMeshProUGUI text;

private void LateUpdate()
{
    if (Input.GetMouseButton(0) && text != null && Camera.main != null)
    {
           int i = TMP_TextUtilities.FindIntersectingLink(text, Input.mousePosition, Camera.main);
           if (i > -1 && text.textInfo.linkInfo.Length > 0)
           {
                Debug.Log("## " + text.textInfo.linkInfo[i].GetLinkID() 
                    + " - " + text.textInfo.linkInfo[i].GetLinkText());
           }
    }
}

N
Nekit Medvedev, 2022-04-07
@NIKROTOS

It sounds like a call to some data structure (database), all the text is pre-written in it, and the link stores the id of the line by which you get the text. Alternatively, you can make a dictionary ( https://metanit.com/sharp/tutorial/4.9.php ) The word will be the key by which the id is obtained, by which the text is already being searched.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question