I'm using a dialogue system to access a computer UI. On activation of the conversation the computer turns on and displays the UI. However, if the player hits escape the rest of the conversation that resets the computer and turns it off doesn't run.
So I'm looking to run code if the player leaves this particular conversation early by hitting escape.
Run Code on Conversation Escape
Re: Run Code on Conversation Escape
Hi,
In code, you can hook into DialogueManager.instance.conversationEnded:
Or add an OnConversationEnd() method to a script that's on the Dialogue Manager or the computer:
If you put it on the computer GameObject, it will only be called if the computer GameObject is the conversation actor or conversation conversant. If you put it on the Dialogue Manager, it will be called for every conversation.
Or add a Dialogue System Events component to the computer GameObject and configure the OnConversationEnd() UnityEvent.
If you only want to run code if the player pressed the Dialogue Manager's Input Settings > Cancel Conversation Input, use an OnConversationCancelled() method instead.
In code, you can hook into DialogueManager.instance.conversationEnded:
Code: Select all
DialogueManager.instance.conversationEnded += OnConversationEnded;
DialogueManager.StartConversation("title");
...
void OnConversationEnded(Transform actor)
{
DialogueManager.instance.conversationEnded -= OnConversationEnded;
if (DialogueManager.lastConversationEnded == "title")
{
// (do your stuff here)
}
}
Code: Select all
void OnConversationEnd(Transform actor)
{
if (DialogueManager.lastConversationEnded == "title")
{
// (do your stuff here)
}
}
Or add a Dialogue System Events component to the computer GameObject and configure the OnConversationEnd() UnityEvent.
If you only want to run code if the player pressed the Dialogue Manager's Input Settings > Cancel Conversation Input, use an OnConversationCancelled() method instead.
Re: Run Code on Conversation Escape
I was able to fix it with your help thank you very much!
Re: Run Code on Conversation Escape
Glad to help!