Author Topic: How to use NGUI 3.0 with non-NGUI UI widgets, related to depth  (Read 5769 times)

kumhon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Hi,
I'm using NGUI 3.0 with Spine skeletal animation plugin. Now with 3.0, I'm having issue of having the spine animation Game object to appear in front of all the NGUI UIWidgets. Below is the picture of the game object hierarchy :

|UIRoot
    |InGameUIPanel
        |UIPanelForSpineGameObjects
            |SpineGameObject (non-NGUI, this should appear in front of all the UISprites from UIPanelForInGameBackground panel)
        |UIPanelForInGameBackground
            |UISprites (Nested)
    |GUIPanel
        |UIButtons

So what happens now is that, some of the UIsprites appears in front and some appears behind the spine game object. Any thoughts/ insight on this please?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to use NGUI 3.0 with non-NGUI UI widgets, related to depth
« Reply #1 on: April 10, 2014, 07:10:59 AM »
NGUI 3 doesn't use Z position at all anymore. Everything is based on depth instead. NGUI creates draw calls, modifying the render queues so that everything is drawn in order. By default it starts at the render queue of 3000 and goes up from there. You can change this on the UIPanel(s).

Check the documentation for the UIPanel.

This may also be useful: http://www.tasharen.com/forum/index.php?topic=776.msg34546#msg34546

kumhon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: How to use NGUI 3.0 with non-NGUI UI widgets, related to depth
« Reply #2 on: April 14, 2014, 09:58:31 PM »
Okay, thanks ^^ . We've decided to change all the rendering queue of the UIPanels and non-NGUI game objects into 3000 and position them with Z-index while still using depth for NGUI objects. Do you foresee any problem with this kind of implementation?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to use NGUI 3.0 with non-NGUI UI widgets, related to depth
« Reply #3 on: April 15, 2014, 09:20:34 AM »
It's just a pain in the ass to do it that way (that's what NGUI 2 used to be like).

kumhon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: How to use NGUI 3.0 with non-NGUI UI widgets, related to depth
« Reply #4 on: April 20, 2014, 10:39:42 PM »
Other than changing the render queue to be the same, do you have any other idea to have NGUI working with non-NGUI GameObjects in depth/z-index layering issue?

layering:
NGUI Sprite (Background)
Spine2D Game Object ( Character with skeletal animation)
NGUI sprite ( Something that covers the character)

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: How to use NGUI 3.0 with non-NGUI UI widgets, related to depth
« Reply #5 on: April 21, 2014, 01:34:27 AM »
You can layer things with multiple cameras. It's not pretty, but it works.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: How to use NGUI 3.0 with non-NGUI UI widgets, related to depth
« Reply #6 on: April 21, 2014, 01:36:22 AM »
With some clever hackings you could possibly get UIPanel to provide your custom renderer with a renderqueue depth as if it was a regular drawcall - that requires some deeper changes though. Could be an interesting addition to NGUI, I think... eh, ArenMook.. eh? *poke poke*

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to use NGUI 3.0 with non-NGUI UI widgets, related to depth
« Reply #7 on: April 22, 2014, 05:13:06 AM »
Useful Stuff sticky has a script in it that can change the render queue of any renderer.

When the UIPanel is set to "Explicit" render queue, you can also set the Sort Order, which is what Unity 2D uses to determine the draw order.