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

因为在项目中 需要在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; 
}


你可能感兴趣的:(【NGUI】Unity中使用NGUI和FingerGestures插件点击UI穿透的问题)