Regarding whether the trigger affects the ray detection of the mouse

Translated by deepl(dot)com:

I’m working on a tower defense type game, I first filled the map with grids and mounted a script for each grid, the script detects if the mouse is on the current grid by using the OnMouseEnter and OnMouseExit functions, and I’ve set the mouse to change color if it’s on the current grid. In addition I have set up a turret, I have mounted a circular collision body to the turret and set it as a trigger, increasing the radius of the circle ensures that the range of the turret is controlled, this also results in the turret’s triggers containing multiple grids, the next point comes, when I have not placed a turret all the grids can be selected, when I place a turret the grids around the turret are not selectable, the performance of which is shown when I When I put the mouse on it, its color doesn’t change, it doesn’t interact with my mouse, and when I de-activate the collision body component of the turret, then it can be selected again, there is no problem with my layer settings, etc. May I ask why this is the case?

Original post:

我正在做一个塔防类型的游戏,我先在地图上铺满了一个一个的格子,并且给每个格子都挂载了一个脚本,脚本中通过OnMouseEnter和OnMouseExit两个函数来检测鼠标是否在目前的格子上,我设置如果鼠标在目前的格子上它的颜色就会发生变化。 此外我设置了炮台,我给炮台挂载了圆形的碰撞体并设置为触发器,增大圆形的半径确保来控制炮台的射程,这也导致了在炮台的触发器内包含了多个格子,接下来重点来了,当我没有放置炮台的时候所有的格子都能被选取,当我放置了一个炮台后,该炮台周围的格子就不能被选取了,表现为我把鼠标放上去它颜色不发生任何变化,不和我的鼠标产生任何交互,而当我把炮台的碰撞体组件取消激活之后就又可以选取了,我的图层设置,等都没有问题,请问这是为什么呢?