Correct usage of Dialogue Manager prefab and linking to UI
Posted: Tue Aug 22, 2023 9:09 am
Hello.
I'm trying to embed Dialogue System to my game. I have a question about correct usage of Dialogue Manager prefab.
In my old GameObject hierarchy I have 'UI' prefab, and somewhere inside it i have 'DialogueUI' GameObject (prefab, but it is not instantiated in runtime, but just preserve inside UI prefab). When I'm working with single scene, I can just drag Dialogue Manager to scene and link my Dialogue UI to it (without canvas link). It works when I have 1 scene.
But I have multiple scenes. Documentations says I should use Dialogue Manager prefab as a singleton with "don't destroy on load". And drag Dialogue Manager to MainMenu. And here is the problem: in MainMenu Dialogue Manager does not have a link to UI, because MainMenu does not have dialogues (obviously).
Each scene loads UI prefab on scene loading, including dialogue UI. So on every scene I have new instance of dialogue UI and I have to tell Dialogue Manager (which is constant between scenes) what is the current dialogue UI now.
I tried to write a custom script which assigns Dialogue UI to Dialogue Manager OnAwake, but this solution does not work.
Therefore I see 2 options.
1. Give up on my old UI hierarchy, use Canvas inside Dialogue Manager, link child canvas and UI prefab to Dialogue Manager, and refactor things to work with this approach.
2. Insert Dialogue Manager into the UI prefab. But in this case Dialogue Manager will not be one object between all scenes, but recreated on every scene with UI. I'm not sure if this is good, may be it is mandatory for it to preserve some runtime data between scenes, and may be this solution will break some functionality.
May be I'm missing something and there is more options. So I'm looking for advices what will be the best solution in my case.
I'm trying to embed Dialogue System to my game. I have a question about correct usage of Dialogue Manager prefab.
In my old GameObject hierarchy I have 'UI' prefab, and somewhere inside it i have 'DialogueUI' GameObject (prefab, but it is not instantiated in runtime, but just preserve inside UI prefab). When I'm working with single scene, I can just drag Dialogue Manager to scene and link my Dialogue UI to it (without canvas link). It works when I have 1 scene.
But I have multiple scenes. Documentations says I should use Dialogue Manager prefab as a singleton with "don't destroy on load". And drag Dialogue Manager to MainMenu. And here is the problem: in MainMenu Dialogue Manager does not have a link to UI, because MainMenu does not have dialogues (obviously).
Each scene loads UI prefab on scene loading, including dialogue UI. So on every scene I have new instance of dialogue UI and I have to tell Dialogue Manager (which is constant between scenes) what is the current dialogue UI now.
I tried to write a custom script which assigns Dialogue UI to Dialogue Manager OnAwake, but this solution does not work.
Therefore I see 2 options.
1. Give up on my old UI hierarchy, use Canvas inside Dialogue Manager, link child canvas and UI prefab to Dialogue Manager, and refactor things to work with this approach.
2. Insert Dialogue Manager into the UI prefab. But in this case Dialogue Manager will not be one object between all scenes, but recreated on every scene with UI. I'm not sure if this is good, may be it is mandatory for it to preserve some runtime data between scenes, and may be this solution will break some functionality.
May be I'm missing something and there is more options. So I'm looking for advices what will be the best solution in my case.