Forum rules - please read before posting.

DialogueUI draw order

Pausing my game fades in a simple black blocking image, in my Canvas.

If I pause the game mid-dialogue (with a DialogueUI displayed over the character's head), the line is displayed on top of my UI.

I see the DialogueUI prefab is spawned to the DontDestroyOnLoad scene. My understanding of how Unity handles canvas draw order is vague, but IIRC it's just 'order in the hierarchy'.

Is there any way to set AC's DialogueUI to draw before my ones? 

Comments

  • The order in the hierarchy is not a reliable way of sorting drawing orders - in my experience it can be kind of random.

    Try changing the "Sort Order" value in the Canvas component.
  • Yeah, I tried that and it resolutely refuses to work. 

    I'd figured it was my Canvas set to ScreenSpace - Camera, and the DialogueUI one at ScreenSpace - overly, but even with some hacks it doesn't seem to make a difference. Will look into it some more. Possibly canvas Render Mode can't be changed at runtime?
  • edited November 2017
    Okay, so because the DialogueUI is a prefab, it needs to be type Overlay because you can't supply a Scene camera... which means it'll always get drawn above any canvases of type ScreenSpace Camera. 

    If I set it up in Awake to be part of my Scene, and set its camera to my UI camera, it displays in the wrong place when set to 'Above Speaking Character', and I thiiiiink that's because it's assuming I'm using ScreenSpace Overlay. Is there a setting somewhere I'm missing that determines which method is used when setting the text's position?
  • Yeah, ironically the UI for the Canvas components aren't always too clear..

    If you need it to assign the Camera field, and/or want it in the scene itself, change the Menu's Source field to "Unity Ui In Scene".  You'll then need to have the prefab placed in each scene file (just test with one for now).

    Positioning works by manipulating the RectTransform boundary you assign in the Menu's properties.  Has that all been set up?

    It might be worth trying the opposite approach, i.e. placing the simple black canvas in the "DontDestroyInLoad" scene as well.  This needn't be done by hooking it up to AC's Menu Manager - it can be done through script too.
  • It's a bit of a faff. Everything's set up properly-  I eventually added a script that moved any DialogueUIs to the active scene, added the UI camera and set it in the appropriate place in my Canvas hierarchy and set the draw order and then... eugh I gave up and just added a script that sets DialogueUI's alpha to 0 if the game's paused, and returns it to 1 when unpaused. Solves the problem. Cleaner. ;)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.