void Update()
{
//返回一条从相机到鼠标位置的射线
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
//Ray ray01 = new Ray(Camera.main.transform.position, Vector3.forward);
RaycastHit hit;
//判断是否碰撞到物体
bool isCollider = Physics.Raycast(ray, out hit);
//bool isCollider01= Physics.Raycast(Camera.main.transform.position, Vector3.forward,
// 10, LayerMask.GetMask("UI", "Enemy", "Player"));
if(isCollider)
{
print(hit.collider.gameObject.name);
}
}