【NGUI】Unity中使用NGUI和FingerGestures插件点击UI穿透的问题

来源:互联网 发布:debian7 安装nginx 编辑:程序博客网 时间:2024/04/27 17:16

因为在项目中 需要在unity中同时使用了NGUI和FingerGestures插件时,当点击NGUI的按钮时,会穿透到场景中,FingerGestures也会捕捉到点击事件。增加以下代码,NGUI的点击事件将被FingerGestures过滤! 

bool ShouldProcessTouch( int fingerIndex, Vector2 position ) { Ray ray = NGUICamera.ScreenPointToRay( position ); bool touchUI = Physics.Raycast( ray, float.PositiveInfinity); return !touchUI; } void Start () { FingerGestures.GlobalTouchFilter = ShouldProcessTouch; }


1 0