Runtime database not showing choices

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
WarriorDogDev
Posts: 2
Joined: Fri May 23, 2025 9:41 am

Runtime database not showing choices

Post by WarriorDogDev »

I'm planning on having dynamic choices that will redirect to other dialogues (each choice will be an NPC in a location that the player can interact with). I've created a runtime database with dialogue entries with the player as the actor, but when I execute the function, the dialogue only shows the last dialogue entry as normal text, not as a choice.

When I try to play the runtime dialogue in the master dialogue view, only the first choice is shown, but as a choice and not as a normal text (the first dialogue entry is blue and the second is gray).And then, when I click on the second dialogue entry in the editor (it changes from gray to blue) and try to play the dialogue again, both choices are displayed.
Result example.png
Result example.png (98.89 KiB) Viewed 8294 times
Editor view 1.png
Editor view 1.png (27.65 KiB) Viewed 8294 times
After clicking in the second dialogue entry
Editor view 2.png
Editor view 2.png (27.53 KiB) Viewed 8294 times

Code: Select all

  public void GenerateActorSelection()
  {
    var database = ScriptableObject.CreateInstance<DialogueDatabase>();
    var template = Template.FromDefault();

    // Create conversation
    //int conversationId = template.GetNextConversationID(database);
    int conversationId = 1000;
    var conversationTitle = "Choices";
    var conversation = template.CreateConversation(conversationId, conversationTitle);
    conversation.ActorID = 1;
    database.conversations.Add(conversation);

    // START node
    var startNode = template.CreateDialogueEntry(0, conversation.id, "START");
    startNode.Sequence = "None()";
    conversation.dialogueEntries.Add(startNode);

    // Dialogue nodes
    var choice1 = template.CreateDialogueEntry(1, conversation.id, string.Empty);
    choice1.ActorID = 1;
    conversation.ConversantID = 1;
    choice1.DialogueText = "Choice 1";
    conversation.dialogueEntries.Add(choice1);

    // Dialogue nodes
    var choice2 = template.CreateDialogueEntry(2, conversation.id, string.Empty);
    choice1.ActorID = 1;
    conversation.ConversantID = 1;
    choice2.DialogueText = "Choice 2";
    conversation.dialogueEntries.Add(choice2);

    // Link from START to Choice 1
    var link = new Link(conversation.id, startNode.id, conversation.id, choice1.id);
    startNode.outgoingLinks.Add(link);

    // Link from START to Choice 2
    var link2 = new Link(conversation.id, startNode.id, conversation.id, choice2.id);
    startNode.outgoingLinks.Add(link2);

    DialogueManager.AddDatabase(database);
    DialogueManager.StartConversation("Choices");
  }
User avatar
Tony Li
Posts: 23251
Joined: Thu Jul 18, 2013 1:27 pm

Re: Runtime database not showing choices

Post by Tony Li »

Hi,

I think there's a typo in this code:

Code: Select all

// Dialogue nodes
var choice2 = template.CreateDialogueEntry(2, conversation.id, string.Empty);
choice1.ActorID = 1;
conversation.ConversantID = 1;
choice2.DialogueText = "Choice 2";
conversation.dialogueEntries.Add(choice2);
The second line there should probably be:

Code: Select all

choice2.ActorID = 1;
WarriorDogDev
Posts: 2
Joined: Fri May 23, 2025 9:41 am

Re: Runtime database not showing choices

Post by WarriorDogDev »

Man, I can't believe I went through all this trouble because of this :lol:
Thanks a lot! It's working like it should now.
User avatar
Tony Li
Posts: 23251
Joined: Thu Jul 18, 2013 1:27 pm

Re: Runtime database not showing choices

Post by Tony Li »

Glad to help!
Post Reply