首页 > 代码库 > 【Unity笔记】鼠标射线由指定层接收

【Unity笔记】鼠标射线由指定层接收

LayerMask mask = 1 << LayerMask.NameToLayer("UI");
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo, 100000.0f, mask.value))     
{
    ...
}

 

【Unity笔记】鼠标射线由指定层接收