Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Roots 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)
-
This just means that whatever you're adding to your panel is on a different layer than the panel itself.
-
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....
-
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?
-
Are all your elements in the prefab in the same, correct layer or only the top element?
-
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...
-
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.