Is it possible to create custom Lua markup tags like [auto] and [f]?
Essentially I'm currently using Rich Text Tags to insert sprites into my Response buttons, such as <sprite name="prayer">.
It's working fine, but I would love a less verbose solution, something like [prayer].
If not possible, is there another solution that would suit the following needs:
- Need custom response buttons or button icons that can easily be assigned to dialogue response entries.
- If custom buttons, need to be able to use same button look for multiple possible entries (so I believe static [position] references would not work)
- Ideally, if the response entries could also have a custom color assigned in the Conversation node editor, that would make troubleshooting at a glance much easier!
Custom Markup Tags?
Re: Custom Markup Tags?
Hi,
You can add a script with OnConversationLine and OnConversationResponseMenu special methods to the Dialogue Manager. Example:
You can add a script with OnConversationLine and OnConversationResponseMenu special methods to the Dialogue Manager. Example:
Code: Select all
void OnConversationLine(Subtitle subtitle)
{
subtitle.formattedText.text = ReplaceSpecialMarkupTags(subtitle.formattedText.text);
}
void OnConversationResponseMenu(Response[] responses)
{
foreach (var response in responses)
{
response.formattedText.text = ReplaceSpecialMarkupTags(response.formattedText.text);
}
}
string ReplaceSpecialMarkupTags(string text)
{
return text.Replace("[prayer]", "<sprite name=\"prayer\">");
}
-
- Posts: 15
- Joined: Thu Dec 16, 2021 2:09 pm
Re: Custom Markup Tags?
Nice one.
I implemented this, however, the text.Replace function seems to not be working.
The events fire (Debug.Log outputs the text from ReplaceSpecialMarkupTags(), but Replace never does any actual replacing.
I've tried it with multiple different words, even single letters. Replace() seems to just return the initial string, unchanged.
I implemented this, however, the text.Replace function seems to not be working.
The events fire (Debug.Log outputs the text from ReplaceSpecialMarkupTags(), but Replace never does any actual replacing.
I've tried it with multiple different words, even single letters. Replace() seems to just return the initial string, unchanged.
Re: Custom Markup Tags?
Hi,
Here's an example scene:
DS_TestReplaceTags_2024-10-25.unitypackage
It replaces "[friend]" with the string "good old buddy old pal".
Here's an example scene:
DS_TestReplaceTags_2024-10-25.unitypackage
It replaces "[friend]" with the string "good old buddy old pal".
-
- Posts: 15
- Joined: Thu Dec 16, 2021 2:09 pm
Re: Custom Markup Tags?
Thanks,
I figured out what was wrong.
I had multiple lines of replace and forgot to assign the text back to itself like this:
I was just going:
which just returned the original text with no replacement.
I figured out what was wrong.
I had multiple lines of replace and forgot to assign the text back to itself like this:
Code: Select all
text = text.Replace("[key]", "replaced key");
text = text.Replace("[other]", "replaced other");
return text;
Code: Select all
text.Replace("[code]", "replaced text")
return text;
Re: Custom Markup Tags?
I can vouch from personal experience that you're not the first to do that.