NGUI Camera's raycast hit through the UI Layer issue

时间:2024-04-15 08:43:16

Raycast into GUI?
http://forum.unity3d.com/threads/raycast-into-gui.263397/

int layer =  << ;
Ray myray = UICamera.currentCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit[] hits = Physics.RaycastAll(myray, 1000.0f, layer);
int layer =  << ;//NGUI layer, TODO modify with your own
void Update()
{
if (Input.GetMouseButtonUp())
{
//UICamera
if (UICamera.currentCamera != null)
{
Ray myray = UICamera.currentCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit[] hits = Physics.RaycastAll(myray, 1000.0f, layer);
if(hits != null && hits.Length > ){//hit the NGUI layer
return;
}
}
    
}
}