Page 1 of 1

Getting Node ID through code

Posted: Fri Oct 30, 2015 3:50 pm
by EWalk13
Hi I was wondering how you get a conversation nodes id through C# code. I need to be able to access these to work in my audio. Also, is there a way to enter a conversation and jump right to a specific node and skip the ones above it?

Re: Getting Node ID through code

Posted: Fri Oct 30, 2015 8:25 pm
by Tony Li
Hi,
EWalk13 wrote:Hi I was wondering how you get a conversation nodes id through C# code. I need to be able to access these to work in my audio.
Every conversation has a conversation ID, and every dialogue entry in the conversation has a dialogue entry ID. If you set the Dialogue Manager's Debug Level to Info, you'll see lines like this:

Code: Select all

Dialogue System: Add Link (Player): ID=12:34 'Hello, world.'
The conversation ID is 12, and the dialogue entry ID is 34.

You can get to any dialogue entry through DialogueManager.MasterDatabase. But I'm guessing you want the current line's IDs. The current dialogue entry is DialogueManager.CurrentConversationState.subtitle.dialogueEntry. So use this:

Code: Select all

var dialogueEntry = DialogueManager.CurrentConversationState.subtitle.dialogueEntry;
int conversationID = dialogueEntry.conversationID; //<-- This is the conversation ID.
int dialogueEntryID = dialogueEntry.id; //<-- This is the dialogue entry ID.      
If you're making a subclass of your dialogue UI class, such as UnityUIDialogueUI, the ShowSubtitle() method also gives you a reference to the subtitle.

You might also find entrytags helpful for your audio. In code, you can use DialogueManager.MasterDatabase.GetEntrytag().

EWalk13 wrote:Also, is there a way to enter a conversation and jump right to a specific node and skip the ones above it?
Pass the dialogue entry ID to DialogueManager.StartConversation():

Code: Select all

DialogueManager.StartConversation("Title", actor, conversant, dialogueEntryID); 
Personally, I don't like working with IDs directly. They're fine, they're stable and reliable, but I feel like the logic is more transparent if I put it inside the dialogue tree's Conditions and Script fields instead. For example, in the Feature Demo, Private Hart's conversation jumps to different sections of the dialogue tree by using Conditions on all the dialogue entries that link from the START entry.

Re: Getting Node ID through code

Posted: Sun Nov 01, 2015 2:00 pm
by EWalk13
Thanks! This is just the information I needed!