Hi Tony,
I would like to put some icons inline in the dialogue text according to the console, for example "press <action1 ... /> to attack".
I'm making a research for put the icons inline but i would like to know if i can parse this stuff in the normal flow of the logic, some method that i can override or something like that or a need to make my own Parser and call before the base.showSubtitle(...) in my UnityUIDialogueUI.cs.
The main idea is to use a generic custom tag like <action1 ... /> and according the console show the device button icon if XBOX show "A" icon, if is PS "X" icon, ...
thanks so much for the help
device buttons image in dialogues
Re: device buttons image in dialogues
Hi Alfonso,
Here are two options. You can choose the one that works best for your needs.
Option 1:
Create a subclass of your dialogue UI, and override ShowSubtitle:
Option 2:
Add a script to the Dialogue Manager that has an OnConversationLine method. Something like this:
You'll probably want to use Regex, not String.Contains and String.Replace. I simplified the code above to make it easier to read.
Here are two options. You can choose the one that works best for your needs.
Option 1:
Create a subclass of your dialogue UI, and override ShowSubtitle:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class MyDialogueUI : UnityUIDialogueUI {
public override void ShowSubtitle(Subtitle subtitle) {
// Extract <action1>:
bool hasAction1 = subtitle.formattedText.text.Contains("<action1>");
subtitle.formattedText.text = subtitle.formattedText.text.Replace("<action1>", string.Empty);
// Show the subtitle without the action tags:
base.ShowSubtitle(subtitle);
// Show the action buttons:
if (hasAction1) ShowActionButton(1); // example.
}
Option 2:
Add a script to the Dialogue Manager that has an OnConversationLine method. Something like this:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class CustomTagParser : MonoBehaviour {
public void OnConversationLine(Subtitle subtitle) {
// Extract <action1>:
bool hasAction1 = subtitle.formattedText.text.Contains("<action1>");
subtitle.formattedText.text = subtitle.formattedText.text.Replace("<action1>", string.Empty);
}