Author Topic: NGUI Panel Behind 3D Object  (Read 8908 times)

shaken

  • Guest
NGUI Panel Behind 3D Object
« on: October 16, 2012, 03:06:12 PM »
Hello,

I'm currently messing around with the free version of NGUI to determine if it can fit our current project needs, one of which is displaying information within the 3D environment.  I have a "Score Board" type object within my scene, and I've been trying to replace it with an NGUI 3D gui panel, but it always ends up displaying over the other 3D objects in the scene.  I have searched for solutions to this issue, and while I did find a post dealing with Depth Sorting, I think it deals with Depth Sorting among various NGUI panels and widgets, so I'm not sure if it is the same issue that I have.  The post that I'm referring to is here: http://www.tasharen.com/forum/index.php?topic=767

I've attached an image of my problem.  The object with the red outline is my original, 3D object, Score Board.  The object with the green outline is the NGUI panel.  You can see in the scene view that the panel is within the "wall" at the bottom of it, but in the game view, the NGUI panel doesn't show up at all.  I'm simply trying to draw the NGUI panel just in front of my original Score Board.

I apologize if this issue requires a simple solution.  I've tried to mess with all kinds of depth and Z values for the panels, cameras, and objects, but I can't figure it out, so I'm here for help.  So, could anyone point out the silly thing that I'm missing?  Or is this a bigger issue than that?

Thanks,
Shawn


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI Panel Behind 3D Object
« Reply #1 on: October 16, 2012, 03:27:16 PM »
Depth-based sorting works only within the same atlas and same panel. In your case you have different objects -- 3D objects, and GUI, which means it's sorted based on the distance to the camera. Unity sorts based on the center of the object's distance to the camera, which is messy.

I suggest using a special shader for your UI that will have its render queue set up to draw after your game objects.

Although it's worth noting that by default that's how it works if you use solid (opaque) shaders for your geometry, and NGUI's default shaders for the UI.

shaken

  • Guest
Re: NGUI Panel Behind 3D Object
« Reply #2 on: October 16, 2012, 05:01:30 PM »
Ah thank you, that helps.  I had to do something similar to get the 3D Text objects that I was creating before to render behind other objects - change the shader.  Should have thought of that here.  Thanks again.