在Google搜到的帖子中提到的方法 有一个地方是错误的(折腾了好久 哎)
http://www.tasharen.com/forum/index.php?topic=127.0
Camera NGUICamera; bool FingerGesturesGlobalFilter( int fingerIndex, Vector2 position ) { Ray ray = NGUICamera.ScreenPointToRay(new Vector3(position.x , position.y, 0)); return !Physics.Raycast(ray, 200, LayerMask.NameToLayer("NGUI")); } void Start() { NGUICamera = UICamera.FindCameraForLayer(8).camera; // function argument expect layer number; not mask FingerGestures.GlobalTouchFilter = FingerGesturesGlobalFilter; // setup the delegate }
Physics.Raycast(ray, 200, LayerMask.NameToLayer("NGUI")) 这里要换成
Physics.Raycast(ray, 200, 1<< LayerMask.NameToLayer("NGUI"))
具体文档参见:
http://docs.unity3d.com/Manual/Layers.html
Best
Eran
时间: 2024-10-24 12:05:55