Ray ray=camera.ScreenPointToRay(Input.mouseposition); RayCastHit hit; If(Physics.Raycasy(ray,out hit)) { If(hit.transform.gameobject.tag==””) { Hit.point.x, Hit.point.y Hit.point.z 表示击中的那个点 } }
NGUI有专门的射线检测函数,绑定在UICamera下面 UICamera.Raycast(Vector3 inPos,out RaycastHit hit); 另外,附上NGUI的在线查询api http://tasharen.com/ngui/docs/class_u_i_camera.html#af876844419d66e76f041eb5e2a473a8d
|