Page 1 of 1

Getting response ID through C# code

Posted: Fri Oct 20, 2023 11:32 am
by OwlionDemanix
Hello !
I would like to retrieve in my C# script the ID of the responses that are actually shown on screen.
I was able to get a Response array using this :

Code: Select all

Response[] responses = DialogueManager.CurrentConversationState.pcResponses;
or this :

Code: Select all

public void OnConversationResponseMenu(Response[] responses) { }
But there is no reference to the corresponding DialogueEntry, so I can't get the ID.
Just to explain a bit why I need the responses ID, it is to quickly link them to a corresponding assets, like an image or a sound stored in Resources folder. There is so much Conversations and Nodes in my database, I want to set it up so I don't have to do the links manualy.
Thanks in advance for your help.

Re: Getting response ID through C# code

Posted: Fri Oct 20, 2023 12:56 pm
by Tony Li
Hi,

The Response object has a destinationEntry property, which is a DialogueEntry. You can also use an OnConversationResponseMenu(Response[]) method in a script on your Dialogue Manager to know when a menu is about to appear. Example:

Code: Select all

void OnConversationResponseMenu(Response[] responses)
{
    foreach (Response response in responses)
    {
        int responseDialogueEntryID = response.destinationEntry.id;
        Debug.Log($"{response.formattedText.text} ID is {responseDialogueEntryID}");
    }
}

Re: Getting response ID through C# code

Posted: Fri Oct 20, 2023 1:08 pm
by OwlionDemanix
Thank you for your answer!
I thought that response.destinationEntry was the DialogueEntry following the response, not the DialogueEntry of the response itself.
I will give it a try!

Re: Getting response ID through C# code

Posted: Fri Oct 20, 2023 1:27 pm
by Tony Li
Glad to help!