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();
}
}
}
DialogueManager.CurrentActor returning null during a conversation
Re: DialogueManager.CurrentActor returning null during a conversation
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:
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>();