Page 1 of 1
Dialogue not loading on "unactive" scene.
Posted: Mon Aug 15, 2016 10:55 pm
by joshcunn
I am creating a game where there are several dialogues across the story, but only the first dialogue loads when I start the game from the beginning. Any conversation after that doesn't load unless I stop the game and restart from that specific scene. Basically, if I'm not on that scene when I start, the dialogue won't load. Anyway to fix this? I am in a 2D game where the mouse and clicking are the only controls. Thanks!
Re: Dialogue not loading on "unactive" scene.
Posted: Tue Aug 16, 2016 3:53 am
by irve
For me this "dialogue only once" happened when I made a broken user interface, which didn't work twice. Don't forget that you can turn on logging on Dialogue Manager component to see any errors of the "second activation".
Re: Dialogue not loading on "unactive" scene.
Posted: Tue Aug 16, 2016 10:20 am
by Tony Li
As @irve writes, temporarily setting the Dialogue Manager's
Debug Level to
Info can be very helpful. Look for yellow warning lines in the Console window, or any lines that start with "Dialogue System:".
Do you have separate Dialogue Manager GameObjects in each scene? If so, do they point to different dialogue databases?
By default, the Dialogue Manager acts as a "persistent singleton." This means it survives scene changes, and like a Highlander there can be only one. The Dialogue Manager maintains its own Lua environment containing all of the runtime changes to variable values, etc. You can still have a separate Dialogue Manager in each scene to make it easy to playtest the scene, but keep in mind that if you're coming in from a previous scene, the Dialogue Manager will be the one from the previous scene.
If you have separate Dialogue Managers with different dialogue databases, here are a few solutions:
1. Use a single database. You can merge your databases using the Merge tool on the Dialogue Editor window's Database tab.
2. Or, use
Extra Databases components in each scene to automatically add the extra databases into the persistent singleton Dialogue Manager. For example, if Scene2 has its own dialogue database Scene2DB, create an empty GameObject, add an Extra Databases component, and assign Scene2DB to the Databases section. Then set the Add Trigger to OnStart and the Remove Trigger to OnDestroy.
3. Or, turn off the persistent singleton configuration by inspecting each of your Dialogue Managers and
unticking
Don't Destroy On Load and
Allow Only One Instance. The disadvantage of this solution is that you won't retain runtime changes to variable values across scene changes, since each Dialogue Manager maintains its own copy of those variables. (Technically you can save the state before leaving the previous scene, and then apply it to the new Dialogue Manager after entering the new scene. If you want info on that, let me know. It's 2 lines of code.)
If none of that helps, please feel free to post more info and/or screenshots here, or send an example project to tony (at) pixelcrushers.com. I'll be happy to take a look.
Re: Dialogue not loading on "unactive" scene.
Posted: Tue Aug 16, 2016 3:34 pm
by joshcunn
Thanks both of you so much! I went with Tony's third idea of unticking those two boxes and that worked perfectly! I believe the issue was I had multiple databases but I was so far along in the game it would've been unbearable to redo all of the conversations. Thanks again!
Re: Dialogue not loading on "unactive" scene.
Posted: Tue Aug 16, 2016 3:52 pm
by Tony Li
If that works for your needs, great!
If you decide in the future that you need variable values to persist across scene changes, you can merge your multiple databases into a single one without having to redo any of them. Just use the Merge tool on the Dialogue Editor window's Database tab. Or you can keep them as separate databases and load them all into memory simultaneously using the Extra Database component.
Re: Dialogue not loading on "unactive" scene.
Posted: Thu Nov 10, 2016 4:25 am
by OneManOnMars
Cool, this was exactly what I was looking for. Had to google exactly once! Thank you Tony Li for the perfect answer.
Re: Dialogue not loading on "unactive" scene.
Posted: Thu Nov 10, 2016 8:01 am
by Tony Li
Happy I could help!
Re: Dialogue not loading on "unactive" scene.
Posted: Wed Nov 16, 2016 11:48 am
by OneManOnMars
Can I create a Dialogue Manager Prefab so if I change it in one scene it also changes in scene 1 and therefore is always up to date?
Re: Dialogue not loading on "unactive" scene.
Posted: Wed Nov 16, 2016 12:04 pm
by Tony Li
Sure. That's what most devs do.
Re: Dialogue not loading on "unactive" scene.
Posted: Wed Nov 16, 2016 12:43 pm
by OneManOnMars
Tony Li wrote:Sure. That's what most devs do.
perfect, thanks for the quick answer.