Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5402351
  • 博文数量: 763
  • 博客积分: 12108
  • 博客等级: 上将
  • 技术积分: 15717
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-28 21:21
个人简介

业精于勤,荒于嬉

文章分类

全部博文(763)

文章存档

2018年(6)

2017年(15)

2016年(2)

2015年(31)

2014年(14)

2013年(87)

2012年(75)

2011年(94)

2010年(190)

2009年(38)

2008年(183)

2007年(28)

分类: iOS平台

2015-09-01 10:58:08

http://blog.csdn.net/chenggong2dm/article/details/39341823

运行NGUI做的背包的时候,报警告:

"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."

点开代码看了一下NGUI的源码,是这样写的:


[csharp] view plaincopy
  1. public void CheckLayer ()  
  2. {  
  3.     if (panel != null && panel.gameObject.layer != gameObject.layer)  
  4.     {  
  5.         Debug.LogWarning("You can't place widgets on a layer different than the UIPanel that manages them.\n" +  
  6.             "If you want to move widgets to a different layer, parent them to a new panel instead."this);  
  7.         gameObject.layer = panel.gameObject.layer;  
  8.     }  
  9. }  

看了一下很简单,就是检查一下层号是否相同,如果不同,报个警告,并强制同层。



解决办法

1,如果背包里的物品都是预制,那么保证预制的层(Layer),与背包一致。

2,也可以在代码里用 the_gameobj.layer = n ; (n为int)  来动态的保持层一致性。


阅读(1823) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~