Page 1 of 1

Overriding Dialogue UI and render modes for a single scene?

Posted: Fri Jan 22, 2021 7:51 pm
by alexlol
Hi,

I have a single scene that uses a different Dialogue UI (an SMS conversation) to the rest of my scenes (basic overhead bubbles).

I'd like to be able to apply some of Unity's post processing and vcam camera effects (i.e a screen shake and some bloom) to the SMS dialogue UI, so I'm setting the render mode to World Space.

This works, but I'm using a Dialogue UI prefab with a default Screen Space Overlay which instantiates in the menu and persists, I'd like to make sure the UI is changed from its default Screen Space to a temporary World Space for the SMS scene, then changed back for the next scene.

The best way I can think to do this is just to have a check on my Game Manager script to get the camera and canvas on scene load and assign everything that way, but I wanted to make sure I wasn't missing something. Is there a more graceful way of temporarily overriding both the Dialogue UI and its render mode already built into Dialogue System? Thanks,

- A

Re: Overriding Dialogue UI and render modes for a single scene?

Posted: Fri Jan 22, 2021 10:09 pm
by Tony Li
Hi,

You could add a script to that scene that assigns the SMS dialogue UI. Example:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
public class UseDialogueUIForScene : MonoBehaviour
{
    public GameObject sceneSpecificDialogueUI; //<--ASSIGN IN INSPECTOR.
    private IDialogueUI previousDialogueUI;
    void Start()
    {
        previousDialogueUI = DialogueManager.dialogueUI;
        DialogueManager.UseDialogueUI(sceneSpecificDialogueUI);
    }
    void OnDestroy()
    {
        DialogueManager.dialogueUI = previousDialogueUI;
    }
}

Re: Overriding Dialogue UI and render modes for a single scene?

Posted: Sat Jan 23, 2021 11:15 am
by alexlol
Thanks, I thought it might be something like that!

For anyone else coming across this post with the same issue - when I switch the render mode to World Space, I need to switch it first to Screen Space- Camera in the line above. This sets the correct scale and position of the canvas first (I don't know why it needs to be done that way but it works!).

Re: Overriding Dialogue UI and render modes for a single scene?

Posted: Sat Jan 23, 2021 2:01 pm
by Tony Li
Oh, I assumed the scene-specific world space UI would already be in its own canvas, and you wouldn't need to change any other canvas's settings. Anyway, sounds like you have it working.