Can I have a 3d object or tk2d sprite between 2 NGUI layers?

Hello everyone,

I am using both NGUI and tk2d for my project.

I have my background as UITexture (NGUI) rendered by NGUI cam, I have objects (prefabs which have child tk2d sprite) which are rendered by a standard cam (not tk2d).

Now I need to have a layer to be on top of everything which means my prefab has to be rendered between the 2 NGUI layers.

I have 3 cams, clear flags, cam depth… are set properly.
One thing I realized that I had my front ngui texture set a layer as “front” but on runtime ngui modified its layer back to NGUI. I changed back to “front” (runtime) but still my prefabs appears on top of everything.

In general how this issue is solved?, note that with unity I am much familiar working with several cams…

The reason it was set back to NGUI automatically is that NGUI will parse all the children widgets underneath its panel (in your case, I guess it’s UI Root) and change their layer. In order for the three layer structure to work, you need to create a new panel with layer front, and bind a camera with culling mask set to this layer and set depth accordingly. The whole structure will look something like this:

  • Object(s) [layer = default; depth = 1]
  • Object Camera [culling mask = default; depth = 1]
  • UI Root [layer = NGUI; depth = 0]
  • Camera [culling mask = NGUI, depth = 0]
  • Front Panel [layer = front; depth = 2]
  • Front Camera [culling mask = 2; depth = 2]