[HOWTO] How To: Start Conversation On Start With Extra Databases

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 20648
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Start Conversation On Start With Extra Databases

Post by Tony Li »

If you're using multiple databases with an Extra Databases component on your Dialogue Manager, and if you have a Dialogue System Trigger set to OnStart, the Dialogue System Trigger may fire before the Extra Databases component has loaded your extra databases. Here's an explanation:
  • The Extra Databases component loads the databases on Start.
  • The Dialogue System Trigger is also set to fire on Start.
  • Unity doesn't define which Start method will run first (Extra Databases or Dialogue System Trigger).
  • If the Dialogue System Trigger's Start runs first, it won't have access to the extra databases because Extra Databases hasn't loaded it yet.
Here are different ways to resolve the issue:
  • Set the Extra Databases component's Add Trigger to OnEnable.
  • Or load your Dialogue Manager in a scene prior to the current scene. This way it'll all be ready when you enter the current scene. This isn't great for playtesting a scene directly, though.
  • Or, assuming you've set up the save system (e.g., by adding a Save System component to the Dialogue Manager), set the Save System component's Frames To Wait Before Apply Data to 1, and set the Dialogue System Trigger's Trigger dropdown to OnSaveDataApplied. This will wait for 1 frame before firing the trigger -- or, if you're loading a saved game, it will wait for the saved game data to have been applied.
  • Or set the Dialogue System Trigger to OnUse. Add a Timed Event component to the same GameObject, set it to Frames > 1, and configure the OnTimeReached() event to call DialogueSystemTrigger.OnUse.
Post Reply