Master Database change during runtime

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Fearinhell
Posts: 44
Joined: Sun Feb 20, 2022 5:53 pm

Master Database change during runtime

Post by Fearinhell »

So I have been working on designing my game and I created databases per scense and had been creating each seperately. Now Im coming back and working on them loading Scene 1 2 3 etc. I am seeing that there isnt an easy way to change databases? I tried the add extra databases and the IDs dont line up so I get random texts from other levels with other NPCs. Is there a way with code to load a different masterdatabase during runtime? Thanks.
Fearinhell
Posts: 44
Joined: Sun Feb 20, 2022 5:53 pm

Re: Master Database change during runtime

Post by Fearinhell »

Or even better yet a way to stop the first dialogue manager from destroying the next one?
Fearinhell
Posts: 44
Joined: Sun Feb 20, 2022 5:53 pm

Re: Master Database change during runtime

Post by Fearinhell »

I might have found the allow only one instance check.
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Master Database change during runtime

Post by Tony Li »

Hi,

If you want to use a fresh Dialogue Manager in each scene, untick the Other Settings > Don't Destroy On Load and Allow Only Once Instance checkboxes.

Alternatively, keep those checkboxes ticked so your global database can continue to exist across scene changes. Assign a "master" database to the Initial Database field. This database (with global quests, variables, etc.) will stay in memory. In each scene, add a GameObject with an Extra Databases component configured to add the scene-specific database on start and remove the database on destroy.

Then run the databases through the Unique ID Tool. (More info: Working With Multiple Databases)

To minimize how often you need to run the Unique ID Tool, set a Base ID for each database (e.g., 1000, 2000, 3000, etc.).
Fearinhell
Posts: 44
Joined: Sun Feb 20, 2022 5:53 pm

Re: Master Database change during runtime

Post by Fearinhell »

Tony,
So with doing this and when I load into my level 2 most of the NPCs do not have the T for talk above them from the on use. If I set On Enter that makes them work but isnt ideal. Have any ideas? Ive compared and compared the one NPC Amanda works everytime but hardly any of the others do. If I mess around a bit sometimes if it hits just right it might get another NPC to work. Thanks
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Master Database change during runtime

Post by Tony Li »

The "T to talk" doesn't come from the Dialogue Manager. It comes from a combination of:
  • The player's Selector or Proximity Selector component. Make sure the Selector's Layer Mask will find the NPCs' layers, or that the Proximity Selector and NPCs have a collider and trigger collider that will register OnTriggerEnter/OnTriggerEnter2D.
  • The player's Selector Use Standard UI Elements component.
  • A Standard UI Selector Elements component. By default, the Dialogue Manager has an Instantiate Prefabs component that instantiates a prefab with Standard UI Selector Elements. Make sure your scene 2's Dialogue Manager instantiates this, or add a Standard UI Selector Elements instance to your scene on your own.
Fearinhell
Posts: 44
Joined: Sun Feb 20, 2022 5:53 pm

Re: Master Database change during runtime

Post by Fearinhell »

Ok Im seeing some of the NPCs do not have trigger colliders yet. But some of the ones that do not I was able to talk to them and they worked fine. OnTrigger Enter setting seems to work everytime over the on use. Ill keep looking this over. It has to be with your first option since some work and some dont. One other thing, after the game has been running on level 2 a few minutes more of the NPCs become talkable. Thanks!
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Master Database change during runtime

Post by Tony Li »

Fearinhell wrote: Sun Sep 04, 2022 9:14 amOne other thing, after the game has been running on level 2 a few minutes more of the NPCs become talkable.
The passage of time by itself shouldn't change anything. I suggest examining what happens in the game during those few minutes.
Fearinhell
Posts: 44
Joined: Sun Feb 20, 2022 5:53 pm

Re: Master Database change during runtime

Post by Fearinhell »

Its when I changed some of the NPCs layer from default to character. How can I address this in the dialogue system? Or is it just easiet to leave on default layer?
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Master Database change during runtime

Post by Tony Li »

Hi,

Add the character layer to the Selector's Layer Mask.
Post Reply