Dialogue manager settings set for different scenes

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
bakershah
Posts: 32
Joined: Sun Oct 19, 2014 10:26 am

Dialogue manager settings set for different scenes

Post by bakershah »

Hi there,

In my game I have a dialogue manager object in every scene because I have different settings for how I want dialogue to play out in different scenes. However I found that when transitioning from one scene to another the dialogue manager settings for that scene are not used instead using the settings from the previous scenes. Is there a fix for this? For my game I have skippable dialogue during gameplay but the next scene is a cutscene cinematic using the dialogue system but I don't want it to be skippable. Thanks!

Baqir Shah
User avatar
Tony Li
Posts: 22100
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue manager settings set for different scenes

Post by Tony Li »

Hi,

To use a different Dialogue Manager in each scene, UNtick "Don't Destroy On Load" and "Allow Only One Instance".

There is one thing to be aware of: Each Dialogue Manager resets the Lua environment. The Lua environment holds the current values of your Lua variables. In the upcoming Dialogue System version 1.5.3, if the same database is assigned to both Dialogue Managers, it will retain the Lua environment when switching scenes.

In the meantime, if you're using 1.5.2 or earlier and want to keep the same Lua environment, here are a couple of different options:

Option 1:
1. Untick "Don't Destroy On Load" and "Allow Only One Instance" on your Dialogue Managers.

2. Before changing scenes, save the Lua environment to PlayerPrefs:

Code: Select all

PlayerPrefs.SetString("Lua", PersistentDataManager.GetSaveData()); 
3. After loading the new scene, restore the Lua environment from PlayerPrefs:

Code: Select all

PersistentDataManager.ApplySaveData(PlayerPrefs.GetString("Lua")); 
Option 2:
Use only one Dialogue Manager. Put it in your startup scene. Keep the checkboxes ticked. In your other scenes, add a small script like this:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class NewDisplaySettings : MonoBehaviour {

    public DisplaySettings newDisplaySettings;
    
    public void Start() {
        DialogueManager.displaySettings = newDisplaySettings;
    }
 } 
Add the script to any GameObject, and set the Display Settings to your liking. You can also put a temporary Dialogue Manager in each scene so you can playtest the scene, but with this option the starting Dialogue Manager will override it during regular play.
Post Reply