I have 2 objects, both have a Box collider 2D.
The first object is on the "Level1" Sorting Layer and has a Tile script attached to it.
The second object is on the "Level0" Sorting Layer and doesn't have any scripts.
![1][1]
![3][2]
The Tile script code is as follows:
void OnMouseDown()
{
Debug.Log(Input.mousePosition.ToString());
}
Whenever I click the top tile, nothing prints in the console unless I click on the red area like I show in the image below (red area = [first box collider] minus [the two box colliders intersection area]).
![2][3]
Why this happens ? Why doesn't the `OnMouseDown` function fire up simply when you click on its collider, since the top tile is on a higher sorting layer than the bottom tile. How does this work ?
[1]: https://i.sstatic.net/8tUTJ.png
[2]: https://i.sstatic.net/QrvEn.png
[3]: https://i.sstatic.net/rP2Jp.png