peterh
Topic Author
Posts: 39
Joined: 13 Mar 2015, 13:50

Render text elements on top of Noesis

03 Oct 2016, 13:16

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?
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Render text elements on top of Noesis

05 Oct 2016, 18:47

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.
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Render text elements on top of Noesis

06 Oct 2016, 19:14

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.
 
peterh
Topic Author
Posts: 39
Joined: 13 Mar 2015, 13:50

Re: Render text elements on top of Noesis

10 Oct 2016, 14:43

I went with the approach to alternate hide/show. It works well enough for my use case.
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Render text elements on top of Noesis

10 Oct 2016, 23:03

Good to know is a valid solution for you!

Who is online

Users browsing this forum: camimamedov, Semrush [Bot] and 29 guests