Author Topic: get rid of warnings  (Read 6009 times)

Roots

  • Guest
get rid of warnings
« on: May 27, 2012, 02:17:11 AM »
Hi,
I keep getting these "You can't place widgets on a layer different than the UIPanel that manages them.
If you want to move widgets to a different layer, parent them to a new panel instead."

I would like to get rid of them. I know they are caused by loading prefabs as items (UI dragpanel contents) in a grid (draggable panel).

I am using this code:
NGUITools.AddChild(grid, prefab);

Any suggestions? (using the latest version)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: get rid of warnings
« Reply #1 on: May 27, 2012, 02:18:47 AM »
This just means that whatever you're adding to your panel is on a different layer than the panel itself.

Roots

  • Guest
Re: get rid of warnings
« Reply #2 on: May 27, 2012, 10:21:37 AM »
Not sure what you mean. The prefab is on the same layer (GUI), and the target panel is also on the same layer (GUI). Would my instance of the prefab not have the same layer defined as the prefab?

What are the key pieces to check so i can get rid of these? I have double checked all things i think that are relevant....

Roots

  • Guest
Re: get rid of warnings
« Reply #3 on: May 27, 2012, 10:51:21 AM »
Hey, thanks for the response. i do usually like to cleane these up regardless. The warning comes from:
if (mPanel != null && mPanel.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);
         gameObject.layer = mPanel.gameObject.layer;
      }

so it seems that it is because they are on different unity layers? am i missing something?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: get rid of warnings
« Reply #4 on: May 27, 2012, 11:23:52 AM »
Are all your elements in the prefab in the same, correct layer or only the top element?

loopyllama

  • Guest
Re: get rid of warnings
« Reply #5 on: May 27, 2012, 11:25:16 AM »
Sorry I was wrong. Your objects are not on the same layers. The code fixes it for you when you see the warning. Add a print to verify the layers are different BEFORE the ngui log warning...

Roots

  • Guest
Re: get rid of warnings
« Reply #6 on: May 27, 2012, 01:34:55 PM »
oops, sorry for wasting people's tiome on this one. I kept checking prefab A settings while i was loading prefab B, turns out of the child items was set to default not the GUI layer causing the warning.