Hello,
The way our project is set is that we have a Master scene that is having all systems and UI related components and Map scenes that contain everything else related to the game (items, terrains, trigger GOs, ...). All my different dialogue UIs are contained under a Dialogue Handler GameObject that is having references for all dialogue UIs I am using.
Now, when I'm hitting a GameObject within, lets say, Map1 scene, I call OnUse() to display the associated dialogue. Howerver, I would like to use Override Dialogue UI to force a specific UI from my Master scene. Obviously, I can't do that using the editor as this is cross scene linking... I was thinking about creating my own custom OverrideDialogueUI class that is deriving from OverrideUIBase, just like you do in sources, but instead of using the public GameObject ui set in the editor (which can't be done), I would fetch it from my Dialogue Handler in the Master scene either upon a OnEnable() or the reference would be sent through an event.
Turns out, it didn't work as I am pretty sure your code is looking for your own implementation of OverrideDialogueUI and not mine. I could do some changes by using the sources version of Dialogue System, but that would be great if there could be a way for me to push the UI I want when using the dll version.
Any idea on what I can do to support my use-case?
Override UI from another scene
-
- Posts: 106
- Joined: Wed Aug 23, 2017 4:10 pm
- Location: Canada
Override UI from another scene
Unity 2022.3.17f1
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Re: Override UI from another scene
Hi,
You can call DialogueManager.UseDialogueUI(GameObject) to set the dialogue UI before calling OnUse(). Will that work for your use-case?
You can call DialogueManager.UseDialogueUI(GameObject) to set the dialogue UI before calling OnUse(). Will that work for your use-case?
-
- Posts: 106
- Joined: Wed Aug 23, 2017 4:10 pm
- Location: Canada
Re: Override UI from another scene
Hello,
Yes this solution works, however it does change the default UI everytime I am calling this. The main purpose of having an override is to use the default UI most of the time and in specific case, use the override UI. Sure, I can keep track of the previously set UI before setting the new one and reverting back to the old one upon ending the dialogue, but being able to use an override would be more elegant in my opinion. Could we just give the UI GO as an optional parameter to OnUse() instead?
Yes this solution works, however it does change the default UI everytime I am calling this. The main purpose of having an override is to use the default UI most of the time and in specific case, use the override UI. Sure, I can keep track of the previously set UI before setting the new one and reverting back to the old one upon ending the dialogue, but being able to use an override would be more elegant in my opinion. Could we just give the UI GO as an optional parameter to OnUse() instead?
Unity 2022.3.17f1
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Re: Override UI from another scene
You're right that it looks for specific subclasses of OverrideUIBase because it needs to handle OverrideDialogueUI and OverrideDisplaySettings slightly differently.
Using the current version of the Dialogue System, can you do what you described and, in OnEnable(), fetch the OverrideDialogueUI value from your Master scene's Dialogue Handler? (You could fetch it by tag if you prefer not to manually enter GameObject names as string.)
For the next release, I can look into adding an additional parameter to OnUse() -- and to DialogueManager.StartConversation() -- to specify a dialogue UI. I need to evaluate any possible side effects before committing to adding this, though.
Using the current version of the Dialogue System, can you do what you described and, in OnEnable(), fetch the OverrideDialogueUI value from your Master scene's Dialogue Handler? (You could fetch it by tag if you prefer not to manually enter GameObject names as string.)
For the next release, I can look into adding an additional parameter to OnUse() -- and to DialogueManager.StartConversation() -- to specify a dialogue UI. I need to evaluate any possible side effects before committing to adding this, though.
-
- Posts: 106
- Joined: Wed Aug 23, 2017 4:10 pm
- Location: Canada
Re: Override UI from another scene
What I did is the following:
It seems to work fine. Do you see any problem with the way I'm setting back the previous Dialogue UI?
Code: Select all
private IEnumerator CoroutineDialogue()
{
var previousDialogueUI = DialogueManager.DisplaySettings.dialogueUI;
// Set the custom UI for this interaction
DialogueManager.UseDialogueUI(Interaction.DialogueUI);
// Start the dialogue
Interaction.Trigger.OnUse(gameObject.transform);
// Wait until I receive the event that the dialogue is done in OnConversationEnd
yield return new WaitUntil(() => _Done);
// Set back the previous dialogue UI
DialogueManager.UseDialogueUI(previousDialogueUI);
Terminated = true;
}
Unity 2022.3.17f1
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Re: Override UI from another scene
That looks fine to me.