Author Topic: Missing something on depths  (Read 5212 times)

pad406

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 62
    • View Profile
Missing something on depths
« on: February 11, 2014, 12:09:36 PM »
I've been scratching my head for ages on this now and I'm obviously missing something. I've read many various posts and info on depth settings, esp re panels and I think I understand it (I'm very new to nGUI, just a week and a bot now). However I have a strange thing happening (have attached a screen shot to show it clearer). My pop up menu, which is basically a tween controlled collection of buttons is not behaving. In the scene view it's perfect, showing in front of all that other panels etc, but will will not show in the game not matter what I do with the depths settings. Any ideas greatly appreciated, I can't afford to loose any more hair!!!  :) :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Missing something on depths
« Reply #1 on: February 11, 2014, 07:54:06 PM »
What version of NGUI? What depth settings do you have on panels? What type of UI are you using, 3D or 2D? You missed some important key points.

Widget in NGUI are always sorted by panel depth first, then by widget depth. That's assuming the panels are left at "automatic" mode. If you choose an explicit Render Queue, then that changes to what NGUI 2 had, and it becomes based on Z position instead.

pad406

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 62
    • View Profile
Re: Missing something on depths
« Reply #2 on: February 12, 2014, 08:12:10 AM »
Hi Aren

Sorry about the lack of info. I'm using 3.4.8 in 2D. I have reduced the scene to a bare minimum now to try and make it easier to find the issue, new screen shot attached (Depth1).
depths are as follows:
UIRoot(2D)     0
Backdrop        1 (has both UIPanel and UISprite, both depths set to 1)
Panel             2 (UIPanel attached)
MenuButton (Sprite) and Label both set to 2

However with both the MenuButton and Label set to 2, sometimes the text doesn't display (see depth2). If I set the label to depth 3, then the text displays fine but I get a warning message in the console (see depth3). The really strange thing is that the depths being reported as wrong from UIwidget are incorrect, I have nothing at depth 8 (I added an extra few debugs to check)

this is the CheckLayer in UIWidget now:

   public void CheckLayer ()
   {
      if (panel != null && panel.gameObject.layer != gameObject.layer)
      {
         Debug.LogWarning("You can't place widgets on a layer different than the UIPanel that manages them.\n" +
            "If you want to move widgets to a different layer, parent them to a new panel instead.", this);
            Debug.Log(panel.gameObject.layer + "--" + gameObject.layer);
            Debug.Log(panel.name + "=" + gameObject.name);
         gameObject.layer = panel.gameObject.layer;
      }
   }

Appreciate the help as always

Paul

P.S. all panels still at automatic

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Missing something on depths
« Reply #3 on: February 13, 2014, 02:36:40 AM »
Quote
Backdrop        1 (has both UIPanel and UISprite, both depths set to 1)
You should never have a panel and a sprite on the same object. Furthermore, you likely don't need the extra panels to begin with. Get rid of that panel.

You also are getting warnings in your log. You should address that. Make sure that you use NGUITools.AddChild to instantiate your items, not Object.Instantiate, as NGUITools method sets the layer properly (and the warning is about layers). Make sure that the object you are instantiating is on the same layer as your UI. You seem to have it on "Default".

pad406

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 62
    • View Profile
Re: Missing something on depths
« Reply #4 on: February 13, 2014, 07:31:54 AM »
Hi Aren

thanks for looking at this. I didn't know about the sprite/panel combination, so I'll modify that. The extra buttons are not being instantiated in the test scene, I created one button and then just copied it. I checked my main program and strangely the depth doesn't seem to be one of the options in the inspector on the prefab, have attached a screen shot.

pad406

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 62
    • View Profile
Re: Missing something on depths
« Reply #5 on: February 13, 2014, 09:44:59 AM »
Hi Aren

I tried it and removing the panel in my test scene works. However when I go back to my main program, no joy. The 'menu' is still hidden behind the panel that I use for the scroll region. I don't know if I have to use a panel for the scroll region, I was going based on the example scene when I set mine up.

Lastly, the log warnings are still coming up when the menu pops up.  The tween is now linked with the UIRoot and it, the sprite for the button and the label for the button are all set a depth of -1. Yet the warnings say that a depth of 8 (UIRoot) is different than 0 (label and sprite).

In the meantime is there any notification on when a tween starts so that I could disable the panel until the user selects an option. I see a finished notification but not a start one and couldn't find anything in searching

« Last Edit: February 13, 2014, 10:05:04 AM by pad406 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Missing something on depths
« Reply #6 on: February 14, 2014, 05:52:04 AM »
Panel depth and widget depth are two different things. Panel depth supercedes all widget depth.

This means that if you have a setup like this:

Panel 1 (Depth 0)
- Widget 1 (depth 1000)

Panel 2 (Depth 1)
- Widget 2 (depth 0)

...your Widget 2 will be on top of widget 1, simply because its panel's depth is higher.