DialogueManager.CurrentActor returning null during a conversation
Posted: Fri Apr 22, 2016 8:45 pm
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();
}
}
}
//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();
}
}
}