DialogueManager.CurrentActor returning null during a conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
hannah
Posts: 17
Joined: Mon Feb 22, 2016 10:42 pm

DialogueManager.CurrentActor returning null during a conversation

Post by hannah »

I'm trying to use the following code to advance dialogue (end the typerwriter effect first) when you left click but aren't mousing over a UI element (such as a button). When I debug.log(dialoguemanager.currentactor) it's return null even though the first line of dialogue has alright been spoken. Any ideas?

//advance dialogue if we aren't clicking on something with a collider
if (Input.GetMouseButtonDown(0))
{
if (Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero).transform == null)
{
UnityUITypewriterEffect typewriterEffect = DialogueManager.CurrentActor.GetComponentInChildren<UnityUITypewriterEffect>();
if ((typewriterEffect != null) && typewriterEffect.IsPlaying)
{
typewriterEffect.Stop();
}
else
{
if (DialogueUI != null) DialogueUI.OnContinue();
}
}
}
User avatar
Tony Li
Posts: 22106
Joined: Thu Jul 18, 2013 1:27 pm

Re: DialogueManager.CurrentActor returning null during a conversation

Post by Tony Li »

Hi,

DialogueManager.CurrentActor and CurrentConversant refer to the primary participants that you specified when you started the conversation -- for example, the Actor and Conversant assigned to the Conversation Trigger, or the transforms you passed to DialogueManager.StartConversation() if you're using code. They don't change with every line.

If you want to get the transform of the current speaker, use DialogueManager.CurrentConversationState:

Code: Select all

var speaker = DialogueManager.CurrentConversationState.subtitle.speakerInfo.transform;
typewriterEffect = speaker.GetComponentInChildren<UnityUITypewriterEffect>(); 
Post Reply