Saving generated conversations

Announcements, support questions, and discussion for the Dialogue System.
devalus
Posts: 52
Joined: Tue Feb 20, 2018 5:09 pm

Saving generated conversations

Post by devalus »

Hi Tony,

I have 2 questions, both relating to the saving & loading of conversations.

1. I am using the Textline addon, and attempting to create a save/load function for my text simulation. I installed the Auto Save Load Component which successfully saves the dialogue location, but would not include the past conversation log when loading back in. I'm trying to have it so that when the player loads the game, past dialogue is also visible.

2. This relates to the previous question. I have 2 scenes with a different conversation on each, and when the conversation on SceneA ends, SceneB is loaded. I'm trying to allow the player to navigate back to SceneA to view the generated past conversation, but it seems like the Dialogue Manager is persistent and all the UI elements are destroyed and populates with SceneB data when it loads. I'm a bit lost as to how I should approach this problem, hoping you could point me in the right direction!

Thanks again for your help!

Amy
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving generated conversations

Post by Tony Li »

Hi Amy,

#1:
To use the Auto Save Load component, just add it to the Dialogue Manager in the "0 Start" scene. When you quit the game, Auto Save Load will tell TextlineDialogueUI to save its state. When you resume the game, Auto Save Load will load the saved scene ("3 Gameplay") and tell TextlineDialogueUI to restore its state, including the past conversation log. You should see lines like this in the log/console window:

Code: Select all

TextlineDialogueUI.OnApplyPersistentData: Restoring current conversation from DialogueEntryRecords
Resuming 'Main Conversation' at entry 5

#2:
Are you ending SceneA's conversation and starting a new conversation in SceneB? If so, when SceneA's conversation ends, it will tell the dialogue UI (TextlineDialogueUI) to Close. When SceneB's conversation starts, it will tell TextlineDialogueUI to Open again. TextlineDialogueUI.Open() clears the history to start with a clean slate. To prevent this, edit TextlineDialogueUI.cs, and comment out line 101 in the Open() method:

Code: Select all

DestroyInstantiatedMessages(); // Start with clean slate. (COMMENT OUT THIS LINE)

A completely different way to approach this is to never end the conversation that started in SceneA. In the Dialogue Editor window, from SceneA's conversation you can link to SceneB's conversation. To add a cross-conversation link, click on a node. In the Inspector, find the "Link To:" dropdown. From the dropdown select "(Another Conversation)".

You can also change scenes while keeping the conversation going by using the LoadLevel() sequencer command in a node's Sequence field.
devalus
Posts: 52
Joined: Tue Feb 20, 2018 5:09 pm

Re: Saving generated conversations

Post by devalus »

Hi Tony,

Regarding problem #1, I have figured out what's causing past conversation log to not be restored when using Auto Save Load. Since I have the Npc Pre Delay Settings set to Based on Text Length = true, I'm getting an error whenever I reload:

ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[UnityEngine.GameObject].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
TextlineDialogueUI.OnApplyPersistentData () (at Assets/Dialogue System Extras/Textline/Scripts/TextlineDialogueUI.cs:297)
UnityEngine.GameObject:SendMessage(String, SendMessageOptions)
PixelCrushers.DialogueSystem.Tools:SendMessageToEveryone(String)
PixelCrushers.DialogueSystem.PersistentDataManager:SendPersistentDataMessage(String)
PixelCrushers.DialogueSystem.PersistentDataManager:Apply()
PixelCrushers.DialogueSystem.PersistentDataManager:ApplySaveData(String, DatabaseResetOptions)
PixelCrushers.DialogueSystem.<LoadLevelFromSaveData>c__IteratorF:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

If I untick NPC pre delay then the auto save load function works as intended. However I need the Npc pre delay, is there a way for both of them to work?

Thanks as always!

Amy
devalus
Posts: 52
Joined: Tue Feb 20, 2018 5:09 pm

Re: Saving generated conversations

Post by devalus »

Also, I noticed that when loading the next scene (I used the LoadLevel() sequencer command) along with Auto Save Load, I get an infinite loop of:
Untitled-2.jpg
Untitled-2.jpg (35.24 KiB) Viewed 1326 times
This occurs even when the next scene has no Dialogue Manager.
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving generated conversations

Post by Tony Li »

Ah, gotta love side effects. :-) I just updated the Textline package to handle AutoSaveLoad when Pre Delay Settings are enabled.

You can download the update here (direct download) or on the Extras page.

You only need to import TextlineDialogueUI.cs. Don't overwrite your content, such as your dialogue database!

I just saw your other post. I'll look into the infinite loop thing.
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving generated conversations

Post by Tony Li »

Hi Amy,
devalus wrote: Mon Feb 26, 2018 11:20 am Also, I noticed that when loading the next scene (I used the LoadLevel() sequencer command) along with Auto Save Load, I get an infinite loop...
Okay, the newly updated 2018-02-26a version is now compatible with the LoadLevel() sequencer command.

The LoadLevel() sequencer command tells the Dialogue System to save its state, which in Textline's case includes the state of the conversation. Then it changes scenes. Finally, it tells the Dialogue System to apply its saved state.

Prior to the 2018-02-26a version, when applying its saved state Textline replayed the last dialogue entry's Sequence. This caused it to replay the LoadLevel() sequencer command, resulting in a loop. Now Textline doesn't replay the last dialogue entry's Sequence.
devalus
Posts: 52
Joined: Tue Feb 20, 2018 5:09 pm

Re: Saving generated conversations

Post by devalus »

Hi Tony,

Thanks for the speedy response!! :D I've updated the script and the problems have resolved. I can now use pre-delays, LoadLevel, and autosave at the same time!

So I've started to tackle #2 of the problem, and after some digging, I found a thread and a package that does precisely what I want: (which is to run multiple conversations simultaneously)
LobbyExample_2017-08-12.unitypackage from viewtopic.php?f=3&t=1054&hilit=loading+ ... n&start=10

I tried it out, and a similar problem is happening. It works perfectly with the previous version of Textline but as soon as I update to 2018-02-26a it does strange things when loading between dialogues. (Sometimes the conversation restarts, sometimes multiple of the same are displayed.) Hoping there's a way for this package to be compatible with the new Textline update?

Sorry for all the questions, and thanks for your time :)

Amy
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving generated conversations

Post by Tony Li »

I'll update that add-on today and post back here when it's ready.
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving generated conversations

Post by Tony Li »

Hi Amy,

Please download and import these two packages:
From the Textline package, you only need to import the updated TextlineDialogueUI.cs script.

I'm pretty sure it handles all the edge cases for the new pre-delay functionality that was added. If not, let me know and I'll fix it.

This is a side note on Auto Save Load: To "restart" your game in the editor when it's stuck in a state you don't want, temporarily untick Auto Save Load's Load On Start checkbox and play the game. Then, after stopping playmode, remember re-tick the checkbox.
devalus
Posts: 52
Joined: Tue Feb 20, 2018 5:09 pm

Re: Saving generated conversations

Post by devalus »

Hey Tony!

Thanks so much for this, works perfectly :D
One question regarding Load On Start, it seems that with this checked the conversation is instantly loaded bypassing the start screen. Is there a way for it to stay on the start screen and load into the game after clicking the navigation button? I unticked Load On Start but this causes the file to not be loaded.

Cheers,
Amy
Post Reply