1.在ngui事件代码中做一个判断
如:
[C#] 纯文本查看 复制代码
viod OnClick()
{
if(UICamera.hoveredObject != null)
{
...
}
}
代表的意思是如果鼠标下面有NGUI物体就执行
2.通过射线来检测
[C#] 纯文本查看 复制代码
private RaycastHit _hit=new RaycastHit();.
if (UICamera.Raycast (Input.mousePosition, out _hit) == false)
{
。。。
}
代表的意思是判断在UI界面层操作.