LinkTo missing after Merging Databases

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
TomGTD
Posts: 6
Joined: Wed Sep 07, 2022 3:50 am

LinkTo missing after Merging Databases

Post by TomGTD »

Hi!

Apologizes in advance for quite a few, and jumbled, questions.

My team and I are using Pixel Crushers Dialogue System for our upcoming title. We are two people working in different databases that we then merge into a Main Database. Or, that's the idea.

The main issue we have at the moment is that we need to hook up all the LinkTo's again after a merge. I assume this has to do with Node ID's, that they're not same as before as they get assigned new ones after a merge? The Nodes affected are the ones that link to another Conversation.

Our game will contain quite a lot of dialogue between many characters, quests etc so testing the isolated Databases and make sure they work to then have to redo that process after the LinkTos disappear post-merge has been proven very time consuming.

I read in the forum about a "Starting ID" feature that sounds interesting, but I couldn't find anything about how to use it. Would this be something that could fix the merge issue?

We're thinking of trying to use multiple Databases so we won't have to merge, but the issue of ID's being the same seem to remain then if I'm not mistaken?
Also, if we were to use multiple Databases, is it possible to safely LinkTo Another Conversation that is in another Database through Dialogue Nodes?

I really appreciate this great forum, I've found many answers through it so far but none yet for my particular question. Thanks in advance, and thank you for this great tool!
/ Tom (they/them)
User avatar
Tony Li
Posts: 21962
Joined: Thu Jul 18, 2013 1:27 pm

Re: LinkTo missing after Merging Databases

Post by Tony Li »

Hi Tom,

On the Dialogue Editor's Database tab > Database Properties foldout, you can set a dialogue database's Base ID. Any new content you create (actors, conversations, etc.) will use ID values starting from this Base ID.

Instead of merging databases, why not use three databases? (See Working With Multiple Databases.)
  • Create a simple "global" database containing your commonly-used actors, variables, etc. Leave its Base ID set to 1. Assign this to the Dialogue Manager's Initial Database property.
  • Create a second database for yourself. Set its Base ID to, say, 10000. Use Sync From to sync the global database's actors, etc., into this database so you can access them.
  • Create a third database for your teammate. Set its Base ID to, say, 20000. Use Sync From to sync the global database's actors, etc., into this database so your teammate can access them.
  • Add an Extra Databases component to your Dialogue Manager. Assign the second and third databases to it.
This way you don't need to do any merging. If you convert your existing databases to do this, you may need to run them through the Unique ID Tool once to make sure they start with unique IDs. But from that point on the different Base IDs should prevent any ID conflicts.
TomGTD
Posts: 6
Joined: Wed Sep 07, 2022 3:50 am

Re: LinkTo missing after Merging Databases

Post by TomGTD »

Hi Tony!

Thanks for the quick reply.

Didn't even cross my mind that it'd be as easy as just assigning the Db Base ID in the tab and that it would automatically count from there. Clever!

We've started looking into multiple databases but our main issue is that we would like some Conversations to be part of our Main Database, such as a Main Quest consisting of many Quests used for progression of the game. This is for organising purposes. We'd then need NPCs' conversations (from another Db) to link into the Main Db's Conversations. This would require us to be able to cross-link across different Databases' Conversations. Is the reply from this thread still relevant for cross-linking? I unfortunately haven't had time to try it out yet.

We are slowly but surely giving up on merging since it seems to be a bit of a hassle and I feel like the Link To Another Conversation may be the last hurdle to get over for this system to work well for us, with Multiple Databases. :)

Thank you for your time!
/ Tom (they/them)
User avatar
Tony Li
Posts: 21962
Joined: Thu Jul 18, 2013 1:27 pm

Re: LinkTo missing after Merging Databases

Post by Tony Li »

Hi,

Yes, you can still use that hack to create cross-conversation links.

Another entirely different direction would be to use a multi-user authoring environment such as articy:draft, Arcweave, or Celtx. You might not want to go that route, especially if you already have a significant amount of content created in Unity, but I thought it was worth mentioning.
TomGTD
Posts: 6
Joined: Wed Sep 07, 2022 3:50 am

Re: LinkTo missing after Merging Databases

Post by TomGTD »

Hello!

Thank you, I'll try that route then!

Yeah, we tried Articy early on but realised it wasn't for us. Dialogue System has seemed to be more up our alley. Thank you for the tips though! :)
/ Tom (they/them)
User avatar
Tony Li
Posts: 21962
Joined: Thu Jul 18, 2013 1:27 pm

Re: LinkTo missing after Merging Databases

Post by Tony Li »

Glad to help!
User avatar
KristianGTD
Posts: 8
Joined: Tue Sep 13, 2022 2:32 am

Re: LinkTo missing after Merging Databases

Post by KristianGTD »

Hi, colleague of Tom here.
We've tried both the paths given in the other thread, and while the first hacky link-to path works, the setup cost and the fact that the cross-database links break every time you need to use the Unique ID Tool makes it a no-go. The second method of calling another database after the conversation isn't how our use case works, so that's also a no-go.

I've tried using a different method of jumping between conversations that was shown here, but for some reason the dialogue UI closes when calling my method. I've made sure by code stepping that it doesn't null out at either the dialogue entry or the conversation state, and it also seems to run all the code in GotoState. Any ideas what might be wrong, or if I'm barking up the wrong tree entirely?

Code:

Code: Select all

    private void Goto(double conversationID, double dialogueID)
    {
      DialogueEntry entry = DialogueManager.masterDatabase.GetDialogueEntry(
        Mathf.RoundToInt((float)conversationID), Mathf.RoundToInt((float)dialogueID));

      ConversationState state = DialogueManager.conversationModel.GetState(entry);

      DialogueManager.conversationController.GotoState(state);
    }
    
User avatar
Tony Li
Posts: 21962
Joined: Thu Jul 18, 2013 1:27 pm

Re: LinkTo missing after Merging Databases

Post by Tony Li »

Hi,

That should work without closing the dialogue UI. As a test, can you create an empty dialogue entry node after the node with your Goto() Lua function? Under some configurations, the conversation may have determined that the dialogue entry doesn't link to anything, so it is prepare to end the conversation.

That may "fix" the issue, although I put fix in quotes because this workaround is still kind of hacky. If it does, you could modify the approach slightly. Instead of using a Goto() Lua function, do this:

1. Add a custom Text field to your dialogue entry. In this custom field, you could store the "links to" conversation ID and entry ID the destination dialogue entry. Or you could store the Title of the destination dialogue entry. In the rest of this reply, I'll assume you're storing the destination entry's Title in a field named "Link To Title".

2. On the Dialogue Manager GameObject, add a script that has an OnConversationPrepareLine method. The Dialogue System will run this method before determining what links to follow. Something like:

Code: Select all

void OnConversationLine(DialogueEntry entry)
{
    var linkToTitle = Field.LookupValue(entry.fields, "Link To Title");
    if (!string.IsNullOrEmpty(linkToTitle))
    {
        var destinationEntry = FindEntryByTitle(linkToTitle);
        if (destinationEntry == null)
        {
            Debug.LogError($"Custom Link To Title didn't find entry with title '{linkToTitle}'");
        }
        else
        {
            // Make sure we haven't already added the link:
            foreach (Link link in entry.outgoingLinks)
            {
                if (link.destinationConversationID == destinationEntry.conversationID && link.destinationDialogueID == destinationEntry.id)
                {
                    return; // We've already added the link
                }
            }
            entry.outgoingLinks.Add(new Link(entry.conversationID, entry.id, destinationEntry.conversationID, destinationEntry.id));
        }
    }
}

DialogueEntry FindEntryByTitle(string title)
{
    foreach (Conversation conversation in DialogueManager.masterDatabase.conversations)
    {
        var entry = conversation.dialogueEntries.Find(x => string.Equals(x.Title, title));
        if (entry != null) return entry;
    }
    return null;
    // Note: You could choose to optimize this by creating a lookup dictionary of <title, entry> at game start.
}
Or, as an alternative, you may find it preferable to use a multi-user editor such as articy:draft or Arcweave.
User avatar
KristianGTD
Posts: 8
Joined: Tue Sep 13, 2022 2:32 am

Re: LinkTo missing after Merging Databases

Post by KristianGTD »

Thanks for the proposed solution!

I found that if I call the code I used above directly in a script Lua field, it only shows the field that I want to jump to, and then keeps running the previous dialogue. The same thing happened if I used a scene-independent event that called the code through a scriptable object. If I on the other hand call the code either from an external script (tested with a menu item calling the method directly) or through a one-frame sequence, everything works just fine, jumping out to the desired conversation and dialogue entry.

I also tested a delayed lua script approach, where I run a coroutine that after 0.05 seconds run my code, and in that case everything also worked.

I feel like there may be something blocking the dialogue system from changing paths in the very first frame of reaching a new dialogue node.

We will be using the sequence-based solution for now, and see if any other issues crop up due to that.
User avatar
Tony Li
Posts: 21962
Joined: Thu Jul 18, 2013 1:27 pm

Re: LinkTo missing after Merging Databases

Post by Tony Li »

Hi,

That code above is designed to prevent having to use a Lua script or sequencer command. As long as the script containing that OnConversationLine method is on the Dialogue Manager, you don't need to set up any other code. Just add a "Link To Title" field to any dialogue entry node that you want to link to another conversation.
Post Reply