Page 1 of 1

What situation/call would create a new Dialogue Manager dynamically

Posted: Mon May 04, 2020 8:08 pm
by bluebuttongames
Hi there again!

So I have a scene with a Dialogue Manager in it as part of a prefab, I load to a different scene without one, I do some database saving stuff, then I load back to the original scene.

The behaviour I have is that a new one is created at Runtime and because only one is permitted my original, prefabbed one gets nuked.

What would cause this behaviour? Is there something being called too early that's creating one on the fly?

Thanks,

BB

Re: What situation/call would create a new Dialogue Manager dynamically

Posted: Mon May 04, 2020 9:32 pm
by Tony Li
Almost all Dialogue System operations require the presence of a Dialogue Manager GameObject.

Version 1.x creates a new, default Dialogue Manager if one doesn't exist when a Dialogue System operation runs.

That was changed in version 2.x, where it just reports a "missing Dialogue Manager" error instead.

Can you put the Dialogue Manager GameObject in that first scene?

Re: What situation/call would create a new Dialogue Manager dynamically

Posted: Tue May 05, 2020 3:30 am
by bluebuttongames
There already is a DialogueManager in the first scene.

So is something being called before the dialoguemanager has initialised maybe?

Would I then see this?

Re: What situation/call would create a new Dialogue Manager dynamically

Posted: Tue May 05, 2020 8:32 am
by Tony Li
Yes, that might happen if something tried to use a Dialogue System operation in an Awake() method that runs before the Dialogue Manager's DialogueSystemController.Awake. As a test, name your Dialogue Manager something unique, such as "Dialogue Manager Good". Then play that first scene. After the scene starts, check if "Dialogue Manager Good" is present in the scene or if a default one has been created. If a default one has been created, here are two options:

1. Call your operation in Start() instead of Awake().

2. Or go to Edit > Project Settings > Script Execution Order, and set the DialogueSystemController's order to be a negative number (i.e., not zero or higher) so its Awake runs first.

Re: What situation/call would create a new Dialogue Manager dynamically

Posted: Thu May 14, 2020 10:44 am
by bluebuttongames
We're back again!

So here's what happens.

Load new scene, it does not contain a dialogueManager, loads my data, at the end when I save my data before loading a new scene a new DialogueManager is created dynamically by your code.

I then in my code find this new DialogueManager and delete it before loading back to my intended scene. All is well.

However in the same session if I now return to that scene, a new one is now longer created, the save asserts stopping the game from loading to the other scene I'm loading to.

At this point I'm thinking of dynamically creating a new one myself at the right time to solve this, but I'm going through major backfips to solve this problem,.

Any ideas?

Re: What situation/call would create a new Dialogue Manager dynamically

Posted: Thu May 14, 2020 11:23 am
by Tony Li
Can you make sure a valid Dialogue Manager exists before calling your save data? For example, put your good Dialogue Manager in the start scene.

I think the problem is that the auto-created Dialogue Manager assigns itself to the static property DialogueManager.Instance. But when you destroy the Dialogue Manager underneath it, the Instance variable is left hanging with an invalid value.