u3射线
Ray ray2 = Camera.main.ScreenPointToRay(Input.mousePosition); //RaycastHit 是一个结构体对象,返回储存的碰撞信息 RaycastHit hitInfo = new RaycastHit(); if( Physics.Raycast(ray2,out hitInfo)){ if (hitInfo.collider.gameObject.name == "Cube"){ Debug.Log("hit_point = "+hitInfo.point); } }