Page 1 of 3
Don't Disable Response Menu and Global Delay
Posted: Thu Feb 06, 2020 10:32 am
by bubucha
Hello,
I have 2 questions:
1) How do you make the response menu stay active during the conversation? During conversations, I don't need the PC Subtitle Panel, and I want the Response Menu to stay active. Right now it disables after each response. There is no Visibility enum (Until Superceded, for example) on the Response Menu.
2) How can I set up a delay for every conversation when the speaker changes? I have an animation when the speaker changes, and I need a delay before the animation plays out. I saw there are commands like Delay() and OnConversationLine() events. Delay() has to be put in every subtitle that switches the speaker, but I don't want to repeat the process for every single conversation (large error chance). OnConversationLine() gets invoked on any line, but I want the delay to only affect the line when the speaker changes.
Thanks for support,
bubucha
Re: Don't Disable Response Menu and Global Delay
Posted: Thu Feb 06, 2020 3:33 pm
by Tony Li
Hi,
bubucha wrote: ↑Thu Feb 06, 2020 10:32 am1) How do you make the response menu stay active during the conversation? During conversations, I don't need the PC Subtitle Panel, and I want the Response Menu to stay active. Right now it disables after each response. There is no Visibility enum (Until Superceded, for example) on the Response Menu.
Unassign the response menu's panel from the StandardUIMenuPanel's Panel field. You can also remove its Animator.
bubucha wrote: ↑Thu Feb 06, 2020 10:32 am2) How can I set up a delay for every conversation when the speaker changes? I have an animation when the speaker changes, and I need a delay before the animation plays out. I saw there are commands like Delay() and OnConversationLine() events. Delay() has to be put in every subtitle that switches the speaker, but I don't want to repeat the process for every single conversation (large error chance). OnConversationLine() gets invoked on any line, but I want the delay to only affect the line when the speaker changes.
You're on the right track with OnConversationLine. Add a script to the Dialogue Manager that has an OnConversationLine method similar to this:
Code: Select all
public int lastSpeakerID = -1;
void OnConversationLine(Subtitle subtitle)
{
if (subtitle.speakerInfo.id != lastSpeakerID)
{
string delayCommand = "Delay(3)";
if (string.IsNullOrEmpty(subtitle.sequence))
{
subtitle.sequennce = delayCommand + "; {{default}}";
}
else
{
subtitle.sequence = delayCommand + "; " + subtitle.sequence;
}
lastSpeakerID = subtitle.speakerInfo.id;
}
Re: Don't Disable Response Menu and Global Delay
Posted: Thu Feb 06, 2020 5:21 pm
by bubucha
Thanks for help. The second question is solved by this:
Code: Select all
private int lastSpeakerId = -1;
private void OnConversationLine(Subtitle subtitle)
{
if (lastSpeakerId == -1)
{
lastSpeakerId = subtitle.speakerInfo.id;
}
else if (subtitle.speakerInfo.id != lastSpeakerId)
{
const string delayCommand = "Delay(0.45)";
subtitle.sequence = string.IsNullOrEmpty(subtitle.sequence)
? $"{delayCommand}; {{default}}"
: $"{delayCommand}; {subtitle.sequence}";
lastSpeakerId = subtitle.speakerInfo.id;
}
}
private void OnConversationEnd(Transform actor)
{
lastSpeakerId = -1;
}
As for the first one, let me explain more details:
Instead of PC Subtitle Panel, I use only Response Menu Panel.
When the conversations starts, I want the NPC Subtitle Panel to become active and play out Show animation AND the Response Menu Panel to become active and play Hide animation. Effectively, this means they both become active at the same time and stay active for the remainder of the conversation.
When the NPC speaks, the Show animation is played on the NPC Subtitle Panel and Hide animation is played on the Response Menu Panel. When he is done and it is time for the player to choose an answer in the Response Menu Panel, the Show animation is played on the Response Menu Panel and Hide on NPC Subtitle Panel.
This continues in both sides until the conversation is done.
How could I achieve this?
Re: Don't Disable Response Menu and Global Delay
Posted: Thu Feb 06, 2020 5:42 pm
by Tony Li
Isn't that just the normal behavior of the dialogue UI? For example, that's the way the quick start tutorial works.
Re: Don't Disable Response Menu and Global Delay
Posted: Thu Feb 06, 2020 6:38 pm
by bubucha
Normal behavior is that the Response Menu plays Hide and deactivates when I click anything, and the NPC Subtitle Panel does the same after he said everything. Instead of that, I want them to play animations, but not get deactivated.
Here is an example capture:
https://www.dropbox.com/s/b228zta0o6igx ... e.mp4?dl=0
I want the portraits to say in the following example (the object to stay active).
P.S I also lied a little bit, I still use the PC Subtitle Panel when there is only one choice, but the idea stays the same. Although I also need to manage which of PC Panel should stay active (Response or Subtitle).
Re: Don't Disable Response Menu and Global Delay
Posted: Thu Feb 06, 2020 10:17 pm
by Tony Li
Hi,
On your subtitle panel GameObjects, replace the StandardUISubtitlePanel script with this subclass:
SubtitlePanel_NoDeactivate.cs
Code: Select all
using PixelCrushers.DialogueSystem;
public class SubtitlePanel_NoDeactivate : StandardUISubtitlePanel
{
protected override void OnHidden()
{
panelState = PanelState.Closed;
}
public override void ClearText() {}
}
To replace StandardUISubtitlePanel while still keeping all of its assignments (Subtitle Text, Portrait Name, etc.), change the Inspector view to Debug mode. Then drag the SubtitlePanel_NoDeactivate script from the Project view into the Script field of the StandardUISubtitlePanel component in the Inspector.
Re: Don't Disable Response Menu and Global Delay
Posted: Fri Feb 07, 2020 9:41 am
by bubucha
Hey once again,
Yeah, your advice with the subclass helped. I then adjusted some things and achieved what I wanted, so the second question is done.
On the other hand, I found out that the first one isn't done yet: The Delay() actually works only after Response Menu. If there are just subtitles, it doesn't Delay.
I have the following code right now:
Code: Select all
private int lastSpeakerId = -1;
private bool conversationStarted;
private void OnConversationStart(Transform actor)
{
conversationStarted = true;
}
private void OnConversationLine(Subtitle subtitle)
{
if (conversationStarted)
{
if (lastSpeakerId == -1 || subtitle.speakerInfo.id != lastSpeakerId)
{
const string delayCommand = "Delay(0.5)";
subtitle.sequence = string.IsNullOrEmpty(subtitle.sequence)
? $"{delayCommand}; {{default}}"
: $"{delayCommand}; {subtitle.sequence}";
lastSpeakerId = subtitle.speakerInfo.id;
}
}
}
private void OnConversationEnd(Transform actor)
{
lastSpeakerId = -1;
conversationStarted = false;
}
OnConversationLine also triggers on the Start node, so I had to use conversationStarted check.
The idea is the same: I want every subtitle to have a delay if it is a new speaker, including the first one, but right now it only works after Response Menu.
Re: Don't Disable Response Menu and Global Delay
Posted: Fri Feb 07, 2020 11:57 am
by bubucha
I think I am on the track of why that happens.
I guess it is related to Closed state. I have this attached to both Response and Subtitle Panels:
Code: Select all
protected override void OnHidden()
{
panelState = PanelState.Closed;
}
I also override StandardDialogueUI with my class:
Code: Select all
public class MyGameUI: StandardDialogueUI
{
public override void ShowResponses(Subtitle subtitle, Response[] responses, float timeout)
{
base.ShowResponses(subtitle, responses, timeout);
conversationUIElements.defaultNPCSubtitlePanel.Close();
}
}
So the Delay only works when I actually did close the panel, and no other times.
Re: Don't Disable Response Menu and Global Delay
Posted: Fri Feb 07, 2020 12:02 pm
by bubucha
I also tried doing this using that MyGameUI:
Code: Select all
public override void ShowSubtitle(Subtitle subtitle)
{
if (lastSpeakerId == -1 || subtitle.speakerInfo.id != lastSpeakerId)
{
subtitle.sequence = string.IsNullOrEmpty(subtitle.sequence)
? $"{DELAY_COMMAND}; {{default}}"
: $"{DELAY_COMMAND}; {subtitle.sequence}";
lastSpeakerId = subtitle.speakerInfo.id;
}
base.ShowSubtitle(subtitle);
}
But this doesn't produce any effect.
Re: Don't Disable Response Menu and Global Delay
Posted: Fri Feb 07, 2020 12:34 pm
by bubucha
Here is a video of what's happening. Delay is set to 3 seconds.
https://www.dropbox.com/s/qx427tolpheqz ... e.mp4?dl=0