Page 1 of 1
Merging Conversations, but keeping Scene-Independent events
Posted: Fri Dec 11, 2020 6:43 pm
by jlhacode
Hi, I'm trying to update the fields of my DialogueEntries by merging DialogueDatabases.
I'm exporting the original database as a CSV, running a python script to change a field value in all of my DialogueEntries, and then attempting to merge it back into the original.
Everything works except for one thing: the Scene-Independent events in the original database get erased after the merge.
I'm guessing exporting the database to a CSV is stripping the Scene-Independent event.
Is there anyway to merge just the DialogueEntry fields of a database?
Re: Merging Conversations, but keeping Scene-Independent events
Posted: Fri Dec 11, 2020 8:39 pm
by Tony Li
Hi,
That is a documented limitation of scene-independent events. They cannot export to any text format. (Scene events, on the other hand, export fine.)
You will have to merge the database(s) within Unity. For your purpose, can you use the Dialogue Editor's Database > Merge Database section? You can untick all checkboxes except for Merge Conversations.
If you have added custom fields and you just want to add them to existing dialogue entries, then on the Templates tab select Menu > Apply Template To Assets.
Re: Merging Conversations, but keeping Scene-Independent events
Posted: Fri Dec 11, 2020 9:16 pm
by jlhacode
I haven't added new custom fields, but rather, I've changed the value of fields in my DialogueEntries.
Merging just the conversations themselves doesn't work because Scene-Independent Unity events get deleted.
It seems like there are only two ways a merge can work for me:
1. If I can merge the new Database into my old database without changing the scene-independent events in the old database.
OR
2. If I can merge the old Database into my new database without changing the new database's DialogueEntry field values.
Re: Merging Conversations, but keeping Scene-Independent events
Posted: Fri Dec 11, 2020 9:48 pm
by Tony Li
You will need to use #1 (merge new database's dialogue entry fields into old database).
Do the dialogue entries have the same IDs?
For example, say Conversation A in the old database has 2 nodes:
Old Database - Conversation A
- ID 0: <START>
- ID 1: "Hello world" + scene-independent event
Does Conversation A in the new database also have the same nodes?
New Database - Conversation A
- ID 0: <START>
- ID 1: "Hello world" + changed fields
If so, then you can write an editor script that goes through each dialogue entry in the old database, looks up the same dialogue entry in the new database, and copies over the fields. Rough example:
Code: Select all
foreach (var oldConversation in oldDatabase.conversations)
{
foreach (var oldEntry in oldConversation)
{
var newEntry = newDatabase.GetDialogueEntry(oldConversation.id, oldEntry.id);
// (Should check for null, etc.)
foreach (var newField in newEntry.fields)
{
var oldField = Field.Lookup(oldEntry.fields, newField.title);
if (oldField != null)
{
oldField.value = newField.value;
}
else
{
oldEntry.fields.Add(new Field(oldField));
}
}
}
}
Re: Merging Conversations, but keeping Scene-Independent events
Posted: Sun Dec 13, 2020 5:02 pm
by jlhacode
A couple questions:
1. How do I get a reference to the databases for the editor script?
- I'm treating the function as a new "Tool" option, [MenuItem("Tools/Merge new database fields to old database")]. Is this the best way to go about it?
2. Do we need to remove the old entry fields before calling oldEntry.fields.Add(new Field(oldField));?
Re: Merging Conversations, but keeping Scene-Independent events
Posted: Sun Dec 13, 2020 6:34 pm
by jlhacode
Nevermind, I got it all figured out after a bit of trial & error with the lesson below:
https://learn.unity.com/tutorial/introd ... -scripting
Thanks Tony! tremendous help as usual
Re: Merging Conversations, but keeping Scene-Independent events
Posted: Sun Dec 13, 2020 6:42 pm
by Tony Li
Hi,
I'm glad you got it all figured out.