Author Topic: Multi-layer UI?  (Read 3094 times)

Dezachu

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Multi-layer UI?
« on: September 28, 2015, 03:42:25 AM »
Hi,

I've been putting off fixing this for some time now; alas, "that" time in the project has arrived. Doh.

I have a 2D background in my scene which uses NGUI. It has a few textures, two of which slide in at the start of the level. On top of that I have my 3D game objects. I then intended to layer a UI on top (showing time remaining, health etc) but it's a bit more difficult than I thought it would be. 2 UI roots seems to make no difference and I can't set two depth layers and assign NGUI elements to it (or can I? Maybe I'm just being dim). I could get away with using NGUI for the 2D background 'UI' and then using the Unity UI for the foreground UI but then I miss out on the features of NGUI which I've become dependent on.

Anyone have any workarounds or solution for this?

Cheers

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Multi-layer UI?
« Reply #1 on: September 28, 2015, 01:23:49 PM »
UIRoot is an optional component. It simply scales the UI so that it's not huge in size. You can have one, several, or none. If I understood you correctly, you want to have something like this:

- Background (NGUI)
- Game stuff
- UI (NGUI)

If that's the case, then you will need either two UIRoots, each set to a different layer so they don't conflict (and make sure their camera's layers are set properly as well)... or you can just only keep the UIRoot on the UI part of it, and set your background to just be a UIPanel with the background sprite/texture underneath it, set to be drawn by some camera other than your UI camera.

Either way you will have 3 cameras. One for the background, one for your game, and one for the UI.

Dezachu

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Multi-layer UI?
« Reply #2 on: September 29, 2015, 11:05:45 AM »
Hey,

Thanks for the response. You're correct in what I'm after and your solution sounds logical. I'll give it a spin and let you know how I get on.

Thanks!

EDIT: Yup, took about 20m of playing around (Unity or NGUI kept setting the layer of all background/UI elements to the same one on run) but all good now. Thank you!
« Last Edit: September 29, 2015, 11:27:40 AM by Dezachu »