Page 2 of 3
Re: Few questions about changing dialogue flow on runtime
Posted: Wed Mar 15, 2017 8:46 pm
by Tony Li
Maybe you're thinking about the custom actor-specific node colors you can set for the node editor?
Anyway, a quick and easy way to set the color of an actor's name as it's shown in dialogue UIs is to add an
Override Actor Name component and wrap the Override Name in rich text codes, such as:
- Override Name: <color=yellow>Private Hart</color>
The only caveat is if you use Variable["Conversant"], since this will be set to "<color=yellow>Private Hart</color>" instead of "Private Hart".
Re: Few questions about changing dialogue flow on runtime
Posted: Thu Mar 16, 2017 12:37 am
by hellwalker
Ah thanks, but would that mess with Lua commands and the like?
For example if i have something like Actor["John"].Disposition that I use to set that actors variable, or get it in Sequences, Lua custom script etc. Will this now be changed to color code version?
Re: Few questions about changing dialogue flow on runtime
Posted: Thu Mar 16, 2017 9:08 am
by Tony Li
You can still use Actor["John"].Disposition.
You just can't use Actor[Variable["Conversant"]].Disposition.
If you need to use Variable["Conversant"], then an alternative way of changing actor name colors is to add a script with an
OnConversationLine method. In this method, put rich text around the speaker's name:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class ActorColor : MonoBehaviour {
public Color color;
void OnConversationLine(Subtitle subtitle) {
if (subtitle.speakerInfo.transform == this.transform) {
subtitle.speakerInfo.Name = "<color=" + Tools.ToWebColor(color) + ">" + subtitle.speakerInfo.Name + "</color>";
}
}
}
Re: Few questions about changing dialogue flow on runtime
Posted: Thu Mar 16, 2017 9:30 am
by hellwalker
Thank you, probably code method will work best for me, as I have up to five actors in some conversations.
Re: Few questions about changing dialogue flow on runtime
Posted: Thu Mar 16, 2017 9:49 am
by Tony Li
Both methods should work fine for as many actors as you want. If you run into any issues, just let me know!
Re: Few questions about changing dialogue flow on runtime
Posted: Thu Mar 16, 2017 8:11 pm
by hellwalker
Thanks,
I only have two conversant added to dialogue starter trigger. I don't have game object associated with others which if I understood is needed for first method right?
Re: Few questions about changing dialogue flow on runtime
Posted: Thu Mar 16, 2017 8:35 pm
by Tony Li
That's correct. A variation of the second method is probably best for your case. You could define a custom field in your Actor template that holds a web color such as "ff0000" for red. Let's say you name that field "NameColor". Then your script becomes:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class ActorColor : MonoBehaviour { // Add to Dialogue Manager.
void OnConversationLine(Subtitle subtitle) {
var webcolor = DialogueManager.MasterDatabase.GetActor(subtitle.speakerInfo.id).LookupValue("NameColor");
subtitle.speakerInfo.Name = "<color=#" + webcolor + ">" + subtitle.speakerInfo.Name + "</color>";
}
}
Re: Few questions about changing dialogue flow on runtime
Posted: Sat Mar 18, 2017 12:25 pm
by hellwalker
How can I delay the PC Response appearing in subtitle ?
Meaning I click on some response and actual dialogue appears x seconds later?
Re: Few questions about changing dialogue flow on runtime
Posted: Sat Mar 18, 2017 5:24 pm
by Tony Li
There's no built-in way to do that. You can create a subclass of UnityUIDialogueUI and override ShowSubtitle. If subtitle.speakerInfo.characterType is CharacterType.PC, you could delay before actually showing it. For example:
Code: Select all
using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem;
public class MyDialogueUI : UnityUIDialogueUI {
public override void ShowSubtitle(Subtitle subtitle) {
if (subtitle.speakerInfo.characterType == CharacterType.PC) {
StartCoroutine(ShowSubtitleDelayed(subtitle));
} else {
base.ShowSubtitle(subtitle);
}
}
IEnumerator ShowSubtitleDelayed(Subtitle subtitle) {
yield return new WaitForSeconds(3); // Wait 3 seconds before showing PC subtitle.
base.ShowSubtitle(subtitle);
}
}
Re: Few questions about changing dialogue flow on runtime
Posted: Thu Mar 23, 2017 1:46 pm
by hellwalker
Umm I think I have one problem with loading that is caused by delayed sequencer command.
For example lets say I start the game, and after 20 seconds dialogue is to launch. and on 10th second I load my game with different chapter. The dialogue from first scene launches 10 seconds later.
So this is what I'm calling now before loading different chapter.
DialogueManager.StopConversation();
PersistentDataManager.LevelWillBeUnloaded();
DialogueManager.ResetDatabase(DatabaseResetOptions.RevertToDefault);
is there something like Sequence.CancelAll that I can call to stop sequences?