Tribute to the original http://blog.csdn.net/chenggong2dm/article/details/39341823
When running a backpack made by Ngui, the newspaper warns:
"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, the parent them to a new panel instead."
Point to open the code to see the source of Ngui, this is written:
[CSharp]View Plaincopy
- 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, the parent them to a new panel instead.", the This );
- Gameobject.layer = Panel.gameObject.layer;
- }
- }
Looked very simple, is to check whether the layer number is the same, if different, report a warning, and force the same layer.
Workaround :
1, if the items in the backpack are prefabricated, then ensure that the prefabricated layers (layer) are consistent with the backpack.
2, you can also use The_gameobj.layer = n in the code; (n is int) to dynamically maintain layer consistency.
You can ' t place widgets on a layer different than the uipanel that manages them.