Author Topic: Widget is always in front  (Read 2257 times)

zetain

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 8
    • View Profile
Widget is always in front
« on: July 17, 2014, 06:03:43 AM »
The problem i have is surely easy to solve nevertheless i do not know how. :(

To block the input to my gameworld while the menu or an dialogue is open i have created a huge collider that should lie behind all other widgets.
In fact no matter what i try -setting the depth of the panel and/or the widget to -200 or whatever-   the collider stays in front of everything. But that was not always the case. 
It could be that the way i structure my gui is a cause for this to happen:
For every part of the GUI - Menu, Dialogues, Cursor - i create a new camera and in the hierarchy of it all widgets that belong to this particular GUI are placed.
Sometimes the panels are above the camera in the hierarchy but i changed that already with no effect.
The camera´s configuration is always the same. Which also means that the depths are equal. I have played around with the depth at runtime but this had no effect either.
I also used the NGUI way and told the panel and the widget of the huge collider to be "pushed back" but as you may guess: no effect.
When i deactivate the gameobject everything is fine. Only that i cannot simply deactivate it cause it serves a function.

My question is now: What can i do to put it behind everything no matter what?
Btw: i am currently using version 3.5.6. I dont want to update but will do so, if it is a problem fixed in a later version

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Widget is always in front
« Reply #1 on: July 18, 2014, 04:31:46 AM »
Create a widget, not a collider. ALT+SHIFT+W, ALT+SHIFT+C, resize to fill the screen (or just anchor to it).

zetain

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Widget is always in front
« Reply #2 on: July 18, 2014, 09:57:50 AM »
The setup is currently exactly the one that you suggest. (And was it before)

Thing is that the very same setup does work in one scene but not in another...
The GUI is a prefab i use in every scene. 

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Widget is always in front
« Reply #3 on: July 19, 2014, 07:43:23 AM »
Can you post a screenshot of your exact hierarchy? And show where the panels and colliders are. The sibling order does not matter, but the parent-child order does.

My supposition is that your collider is on its own gameobject without any widget or panel, which makes it just be in 3d - this does not play well with the regular depth settings in widgets and panels.

If you have your game rendered by a separate layer (default?), then your UI should be in a separate layer from this and have its UICamera have a higher depth on the Camera component (NOTE this is not the same depth as is on widget and panel). This will ensure that your UI is always drawn above the game.

To make a collider that covers the whole screen and thus blocks input to the game world, you could create a simple structure like this inside your UI:

*UIRoot
** BlockerPanel (UIPanel, depth= -1)
***BlockerWidget (UIWidget, depth=0, Anchor: Unified target: BlockerPanel left to left, right to right etc offset 0 px; Attach boxcollider and tick the box in UIWidget to resize box collider to its size)
**Other UI (UIPanel depth 0+)

Does this help you?

zetain

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Widget is always in front
« Reply #4 on: July 22, 2014, 03:03:10 AM »
@ Nicki: I also have tried what you suggest but that did not work out either.

But its really weird: yesterday without me doing or changing anything it suddenly started to work again.
I dont know why... that is not really convenient since i could unknowingly make the same mistake again. whatever it might have been. maybe the metafile was corrrupted or some other Unity hiccup.