Author Topic: How to differentiate layer?  (Read 4677 times)

leegod

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 90
    • View Profile
How to differentiate layer?
« on: December 02, 2014, 02:46:53 AM »
So I have ngui objects in one UIRoot and I want some of its children have different layer than UIRoot because I want them show from another camera.(perspective camera for enable 3d-like effect)

But ngui seems automatically set their layer same with UIRoot's layer.

How can I avoid this?




Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: How to differentiate layer?
« Reply #1 on: December 02, 2014, 11:57:47 AM »
NGUI's UIPanel will fight you over this. Take a look inside the UIPanel.UpdateLayers (line 1495) and comment out the

  1. //                      NGUITools.SetChildLayer(cachedTransform, mLayer);
  2.  

that should fix your problem. The problem is that UIPanel is very indiscriminate on what it changes the layer of - every child and subchild is just changed, no matter what layer it happens to be in, or if it's supposed to be rendered by something else. This is nice for consistency of the UI, but terrible if you're doing more tricky multi-layer work.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to differentiate layer?
« Reply #2 on: December 02, 2014, 12:21:32 PM »
It's generally not a good idea to mix UI and 3D objects in the same hierarchy. Especially since they are drawn using different cameras.