Skip to content
Snippets Groups Projects
Commit eeaacd69 authored by Karel Ševčík's avatar Karel Ševčík
Browse files

Add event callbacks to start and end of dialogue

parent 985e2bb5
No related branches found
No related tags found
1 merge request!33Dialogue events
......@@ -2,6 +2,7 @@
using UnityEngine;
using UnityEngine.UI;
using System.Linq;
using UnityEngine.Events;
 
namespace Nudle.Scripts.Dialogue
{
......@@ -18,6 +19,8 @@ namespace Nudle.Scripts.Dialogue
private Dialogue currentDialogue;
private List<Button> choiceButtons;
 
internal UnityEvent OnExit;
internal void Start()
{
choiceButtons = new List<Button>();
......@@ -115,6 +118,9 @@ namespace Nudle.Scripts.Dialogue
{
animator.SetBool("IsOpen", false);
currentDialogue = null;
if (OnExit != null)
OnExit.Invoke();
OnExit = null;
return;
}
StartDialogue(next);
......
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
 
namespace Nudle.Scripts.Dialogue
......@@ -12,6 +13,9 @@ namespace Nudle.Scripts.Dialogue
public Vector2 FloatingTextOffset = new Vector2(0f, 50f);
public bool ForceStart;
 
public UnityEvent OnStart;
public UnityEvent OnExit;
private Text Floater;
 
private DialogueManager GetDialogueManager() => FindObjectOfType<DialogueManager>();
......@@ -24,7 +28,11 @@ namespace Nudle.Scripts.Dialogue
{
if (DialogueUtil.AreAllSet(possibleDialogue.RequiredSetFlags) && DialogueUtil.AreAllUnset(possibleDialogue.RequiredUnsetFlags))
{
GetDialogueManager().StartDialogue(possibleDialogue);
var dm = GetDialogueManager();
dm.OnExit = OnExit;
dm.StartDialogue(possibleDialogue);
if (OnStart != null)
OnStart.Invoke();
return;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment