Hi, I would like to understand the best practice to handle my scenario:
1. In the first scene there are 3 always opened conversations with different UIs, 1 of which part of a canvas rendered outside the Dialogue Manager object (as it needs to be part of the World Space and move around)
2. Scene 2 is identical to scene 1, the only change in terms of Dialogue Manager is that the content of the conversations is different.
The issues I'm having right now are:
1. Override Ui losing their reference and thus all conversation revert to be displayed to the default UI
2. If a conversation from the previous scene have responses displayed those are displayed for a few seconds during scene 2
3. The canvas rendered outside dialogue manager triggers a MissingReferenceException (StandardDialogueUI has been destroyed but you are trying to access it), likely because Dialogue Manager is trying to use the original canvas/UI instead of the copy present in the scene.
I think that due the nature of my project if I could remove the "DontDestroyOnLoad" property of Dialogue Manager so that each scene is independent I would solve all the issues, is there a way to do that? Or is there a better solution?
Thanks!
Scene change and override UI assets / Dialogue Manager DontDestroyOnLoad
Re: Scene change and override UI assets / Dialogue Manager DontDestroyOnLoad
Hi,
Untick the Dialogue Manager's Other Settings > Don't Destroy On Load checkbox and the Input Device Manager component's Singleton checkbox. If you've added a Save System component to the Dialogue Manager, you must move it to a separate GameObject since the Save System component always marks its GameObject as Don't Destroy On Load.
Re: Scene change and override UI assets / Dialogue Manager DontDestroyOnLoad
This works perfectly thanks Tony!
Since this resets the variables in Dialogue Manager I was looking for a workaround and I tried to use the save system.
The plan is to:
1. Save the variables at the end of a scene with the "Save Current Scene" disabled in the Save System script.
2. Load them at the start of the next scene
3. Re-enable the checkbox in the save system script and save the game on a different slot. (I plan to only have automated saves, once at the start of a scene)
So for example Slot 1 will always store variables to load at scene start and Slot 2 the actual scene to load from the main menu.
The only problem is that I can't enable/disable that checkbox live. Could it be possible, maybe by making it a public bool?
I use Playmaker but setting a property shows 2 bool settings with other names, which I tried anyway just in case. Also looked at the scripts (Save System and GameSaver) and while those are very well commented (props to you!) I couldn't find a reference :/
Btw feel free to tell me if the whole idea is stupid, I wonder sometimes if my "solutions" are over-complicated due to my lack of knowledge...
Since this resets the variables in Dialogue Manager I was looking for a workaround and I tried to use the save system.
The plan is to:
1. Save the variables at the end of a scene with the "Save Current Scene" disabled in the Save System script.
2. Load them at the start of the next scene
3. Re-enable the checkbox in the save system script and save the game on a different slot. (I plan to only have automated saves, once at the start of a scene)
So for example Slot 1 will always store variables to load at scene start and Slot 2 the actual scene to load from the main menu.
The only problem is that I can't enable/disable that checkbox live. Could it be possible, maybe by making it a public bool?
I use Playmaker but setting a property shows 2 bool settings with other names, which I tried anyway just in case. Also looked at the scripts (Save System and GameSaver) and while those are very well commented (props to you!) I couldn't find a reference :/
Btw feel free to tell me if the whole idea is stupid, I wonder sometimes if my "solutions" are over-complicated due to my lack of knowledge...
Re: Scene change and override UI assets / Dialogue Manager DontDestroyOnLoad
Hi,
If you want to continue using a different Dialogue Manager in each scene, you can use the PlayMaker action "Record Savegame Data" before changing scenes and "Apply Savegame Data" after changing scenes. Record Savegame Data will store the current variable values in a PlayMaker string.
---
If you want to go back to using a single Dialogue Manager that survives scene changes, so you don't have to worry about manually saving and loading variables for scene changes, the key is to make sure that there are no inspector assignments between GameObjects in the Dialogue Manager hierarchy and GameObjects outside of the Dialogue Manager hierarchy.
For example, say in scene 1 you have 3 conversations:
Then handle scene 2 the same way: Conversations using Override Dialogue UI should point to prefabs or to a dialogue UI in a Canvas that's outside the Dialogue Manager's hierarchy.
If you want to continue using a different Dialogue Manager in each scene, you can use the PlayMaker action "Record Savegame Data" before changing scenes and "Apply Savegame Data" after changing scenes. Record Savegame Data will store the current variable values in a PlayMaker string.
---
If you want to go back to using a single Dialogue Manager that survives scene changes, so you don't have to worry about manually saving and loading variables for scene changes, the key is to make sure that there are no inspector assignments between GameObjects in the Dialogue Manager hierarchy and GameObjects outside of the Dialogue Manager hierarchy.
For example, say in scene 1 you have 3 conversations:
- Conversation 1A uses the Dialogue Manager's default dialogue UI (i.e., the one assigned to the Dialogue Manager's Dialogue UI field).
- Conversation 1B uses a different screen space UI.
- Conversation 1C uses a different world space UI.
Then handle scene 2 the same way: Conversations using Override Dialogue UI should point to prefabs or to a dialogue UI in a Canvas that's outside the Dialogue Manager's hierarchy.
Re: Scene change and override UI assets / Dialogue Manager DontDestroyOnLoad
Thanks Tony once again for your help.
I tried both solutions, and they both worked fine.
Edit: I actually found an extreme case scenario which likely would not affect the final game just the testing. Basically if a conversation is still ongoing (not simply displaying, but actually rendering the text for example because of delay effect or typewriter effect) when the scene change is triggered dialogue manager will keep advancing it and when trying to display the responses it will look for an UI that doesn't exist anymore triggering the error I mentioned as "3" in my first post.
No big deal as I can ensure all conversations are not running with a simple wait timer.
Judging by your manual/tutorials and the fact that you explained me how to do it it seems that keeping one instance of dialogue manager generated in the first menu screen is best practice so I'll trust your experience and try to stick to that if possible.
I tried both solutions, and they both worked fine.
Edit: I actually found an extreme case scenario which likely would not affect the final game just the testing. Basically if a conversation is still ongoing (not simply displaying, but actually rendering the text for example because of delay effect or typewriter effect) when the scene change is triggered dialogue manager will keep advancing it and when trying to display the responses it will look for an UI that doesn't exist anymore triggering the error I mentioned as "3" in my first post.
No big deal as I can ensure all conversations are not running with a simple wait timer.
Judging by your manual/tutorials and the fact that you explained me how to do it it seems that keeping one instance of dialogue manager generated in the first menu screen is best practice so I'll trust your experience and try to stick to that if possible.
Re: Scene change and override UI assets / Dialogue Manager DontDestroyOnLoad
Hi,
Sounds good. It's easier in the long run to use one Dialogue Manager. Just remember not to assign references in the inspector between GameObjects that are Don't Destroy On Load (like the Dialogue Manager) and GameObjects that aren't Don't Destroy On Load (like other scene objects).
Sounds good. It's easier in the long run to use one Dialogue Manager. Just remember not to assign references in the inspector between GameObjects that are Don't Destroy On Load (like the Dialogue Manager) and GameObjects that aren't Don't Destroy On Load (like other scene objects).