Page 1 of 1

Render text elements on top of Noesis

Posted: 03 Oct 2016, 13:16
by peterh
In my Unity application, I need to print some text on top of Unity to print out some debug information. I need this text to appear above any Noesis elements and/or Unity GUI elements. The style of the text does not really matter as it's only for debug reasons, the only requirement is that it never should be obscured by other UI elements.
I can't seem to get this to work in a satisfactory way. I have tried the following approaches:

a) Have a Unity camera with a different render depth than my Noesis Camera and use Unity GUI components.
- The Unity GUI elements still render below the Noesis GUI.

b) Use a Noesis GUI Popup to render the text above other Noesis GUI elements.
- This works in all cases except for the case when other Noesis GUI Popups are used. If I render the text, then open another Popup, the Popups stack in order of appearance, meaning the debug text is obscured by the newer popup.
This seems to be the more promising approach, but I need a way to allow the Popup with the debug text to always appear on top of other popups. Is there a way to make this happen?

Re: Render text elements on top of Noesis

Posted: 05 Oct 2016, 18:47
by sfernandez
Hi Peter,

Following your Popup approach you can do a bit of a hack and hide/show the debug information popup on each frame, so it always appears on top of other popups:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Grid x:Name="LayoutRoot">
        ...
    </Grid>

    <Popup x:Name="DebugLayerPopup">
        <Grid x:Name="DebugLayerRoot">
            ...
        </Grid>
    </Popup>

</Grid> 
public class DebugInfoBehavior: MonoBehavior
{
  Popup _debugLayerPopup;

  void Start()
  {
    var gui = GetComponent<NoesisGUIPanel>()
    var content = gui.GetContent();
    _debugLayerPopup = (Popup)content.FindName("DebugLayerPopup");
  }

  void Update()
  {
    _debugLayerPopup.IsOpen = false;
    _debugLayerPopup.IsOpen = true;
  }
} 
Maybe is something you already tried.

There is no simple way to draw some elements on top of everything else because, as you noticed, Popups just stack on top as they are shown.

Another solution may be to use RenderTextures to draw the UI in the order you want, but seems too much for just some debug information.

Re: Render text elements on top of Noesis

Posted: 06 Oct 2016, 19:14
by jsantos
a) Have a Unity camera with a different render depth than my Noesis Camera and use Unity GUI components.
- The Unity GUI elements still render below the Noesis GUI.
Have you tried this but using a NoesisGUI component? I mean, a camera with different render depth and a NoesisGUI component attached to render the debug text.

Re: Render text elements on top of Noesis

Posted: 10 Oct 2016, 14:43
by peterh
I went with the approach to alternate hide/show. It works well enough for my use case.

Re: Render text elements on top of Noesis

Posted: 10 Oct 2016, 23:03
by jsantos
Good to know is a valid solution for you!