unity之警告“You can't place widgets on a layer different than the UIPanel that manages them.”

做项目时,用到NGUI,出现了很多警告如下:“You can't place widgets on a layer different than the UIPanel that manages them.",而且越来越多,拖慢性能。

点开警告,代码如下:

/// <summary>
	/// Check to ensure that the widget resides on the same layer as its panel.
	/// </summary>

	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);
			gameObject.layer = panel.gameObject.layer;
		}
	}
代码里写的很清楚,就是ui里父对象与子对象的layer不同,会把所有layer转换为一致,这样会是性能变低所以指定为同一层就可以解决


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值