NGUI Camera's raycast hit through the UI Layer issue
Raycast into GUI?
http://forum.unity3d.com/threads/raycast-into-gui.263397/
int layer = 1 << 15; Ray myray = UICamera.currentCamera.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits = Physics.RaycastAll(myray, 1000.0f, layer);
int layer = 1 << 15;//NGUI layer, TODO modify with your own void Update() { if (Input.GetMouseButtonUp(0)) { //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 > 0){//hit the NGUI layer return; } }
} }