Receive dialogue data when each conversation node start

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Luphan
Posts: 13
Joined: Wed Jun 07, 2023 5:39 am

Receive dialogue data when each conversation node start

Post by Luphan »

Hi, We are now working on a quite complex animation system and would like to attach data on each conversation node that when each node trigger, I can receive an information data set from dialogue system which contains actor, emotion id, animation id, etc... Most important of all, we want our artist to edit it. so we might like to modify that data easly from the inspector of the node

I know that there are sequence and script utility which is very flexable to use, but it also has the disadvantage as string. If something type wrong or maybe having need to rename method, variable name. It will be difficult to track all the conversation node that use it the keyword.

so we are wondering if there's a way for as to add one more serialized data at the buttom of the conversation node's inspector? or is there any other way that you suggest?
User avatar
Tony Li
Posts: 22125
Joined: Thu Jul 18, 2013 1:27 pm

Re: Receive dialogue data when each conversation node start

Post by Tony Li »

Hi,

Yes, you can do this. Add fields to the dialogue entry template (see Templates), and tick the Main checkbox:

customFields.png
customFields.png (47.71 KiB) Viewed 317 times

They will appear in the Inspector like this:

customFieldsInspector.png
customFieldsInspector.png (35.4 KiB) Viewed 317 times

In the screenshots above, the field type is Text. You may want to change this to a dropdown menu (e.g., Emotion ID = Happy, Sad, Angry, etc.). To do that, define a Custom Field Type.

Then add a script with an OnConversationLine method to the Dialogue Manager GameObject. In this method, access the fields:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    string emotionID = Field.LookupValue(subtitle.dialogueEntry.fields, "Emotion ID");
    // Do something with emotionID.
}
Luphan
Posts: 13
Joined: Wed Jun 07, 2023 5:39 am

Re: Receive dialogue data when each conversation node start

Post by Luphan »

Thank you! Tony!

You really explain it clearly and make it so easy to understand!
User avatar
Tony Li
Posts: 22125
Joined: Thu Jul 18, 2013 1:27 pm

Re: Receive dialogue data when each conversation node start

Post by Tony Li »

Glad to help!
Post Reply