1 << 10 检测第10层
~(1 << 10) 检测除了第10之外的层。
~(1 << 0) 检测所有的层。
(1 << 10) | (1 << 8) 检测第10和第8的层。
RaycastHit hit; Vector3 dir; //目标向量 float dis; //最大距离 bool res = Physics.Raycast(self.position, dir, out hit, dis,~(1<<10)); //检测除第10层之外的 bool res2 = Physics.Raycast(self.position, dir, out hit, dis,~(1 << LayerMask.NameToLayer("Monster"))); //检测除怪物层之外的