An "on conversation end" event is sent to the Dialogue Manager GameObject and the two primary participants (e.g., player and NPC). This event is used by the Dialogue System Events component and scripts with OnConversationEnd methods.
If the specific conversation runs on a specific NPC, you can add the Dialogue System Events component to that NPC. Or you can add a Dialogue System Trigger set to OnConversationEnd to that NPC.
If not, you can write a script that uses the property DialogueManager.lastConversationStarted, which is the title of the last conversation that played.
Add an OnConversationEnd method to the Dialogue Manager (or player), or hook up a method to Dialogue System Events, that provides UnityEvents for specific conversations. Or, if you don't want to put it on the Dialogue Manager or one of the primary participants, hook into the C# event DialogueManager.instance.conversationEnded instead.
Example:
Code: Select all
using UnityEngine;
using UnityEngine.Events;
using PixelCrushers.DialogueSystem;
public class ConversationEndEvents : MonoBehaviour
{
[System.Serializable]
public class ConversationEndEvent
{
[ConversationPopup] public string conversation;
public UnityEvent onEnd;
}
public ConversationEndEvent[] conversationEndEvents;
private void OnEnable()
{
DialogueManager.instance.conversationEnded += RunEventsOnConversationEnded;
}
private void OnDisable()
{
DialogueManager.instance.conversationEnded -= RunEventsOnConversationEnded;
}
private void RunEventsOnConversationEnded(Transform actor)
{
foreach (ConversationEndEvent endEvent in conversationEndEvents)
{
if (endEvent.conversation == DialogueManager.lastConversationStarted)
{
endEvent.onEvent.Invoke();
}
}
}
}