title: How to detect multiple/Overlapping GameObjects with the EventSystem?
body: <p>What I try to achieve: Toothbrush should show up wherever the user clicks inside <code>BoxCollider</code> <code>A</code>, including space inside <code>BoxCollider</code> <code>B</code>. But apparently clicking inside <code>B</code> will not show the toothbrush (OnPointerDown is not being triggered).</p>
  
  <p>What I have tried: Changing the order of the layers.</p>
  
  <p>Toothbrush is showed after user clicks inside box collider <code>A</code>, but if the user clicks inside box collider <code>B</code>- the toothbrush will not show up, which means <code>OnPointerDown</code> is not triggered.</p>
  
  <p>I think it is because of the overlapping of one <code>BoxCollider2D</code> inside another <code>BoxCollider2D</code>. In my case <code>B</code> inside <code>A</code>, I assume that is the culprit, but I have no idea how to solve it or if maybe there is another method to implement <code>OnPointerDown</code>?</p>
  
  <p>I am using <code>Perspective</code> camera. but in this scene all elements are in same <code>z position</code> which is 0. Is it possible to trigger IPointerHander event in every respective <code>BoxCollider2D</code> ?</p>
  
  <p><a href="https://i.stack.imgur.com/spQ7f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/spQ7f.png" alt="enter image description here"></a></p>
  
  <h3>DragableObject.cs</h3>
  
  <p>This script is attached to the toothbrush. The <code>BoxCollider2D</code> A also belongs to toothbrush.</p>
  
  <pre><code>public void OnPointerDown(PointerEventData eventData)
  {
      Debug.Log("pointer down");
  
      if (GetComponent&lt;DragableObject&gt;() == null)
          return;
  
      currentObject = GetComponent&lt;DragableObject&gt;();
  
      MeshRenderer renderer = GetComponent&lt;MeshRenderer&gt;();
  
      if (ShowOnTouch)
          ShowObject();
  
      // Store original state
      originalPosition = transform.position;
      originalOrderLayer = renderer.sortingOrder;
      // Snap to mouse
      Vector3 newPos = cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 30));
      newPos.z = 30;
      transform.position = newPos;
  
      if (BringToFront)
      {
          if (renderer != null)
          {
              renderer.sortingOrder = 90;
          }
      }
  
      ObjectActive.Invoke();
  }
  </code></pre>
  
  <h3>TargetListener.cs</h3>
  
  <p>This script is attached to <code>BoxCollider2D</code> B.</p>
  
  <pre><code>public void OnPointerDown(PointerEventData eventData)
  {
      for (int i = 0; i &lt; Affectors.Count; i++) 
      {
          if (Affectors [i] == DragableObject.currentObject)
          {
              DragableObject.currentObject.OnEnterTarget(transform);
  
              ITriggerEffect[] iTrigger = GetComponents&lt;ITriggerEffect&gt;();
  
              for (int j = 0; j &lt; iTrigger.Length; j++) 
              {
                  Debug.Log("iTrigger enter");
                  Debug.Log(iTrigger [j]);
                  iTrigger [j].Execute(eventData, PointerState.Down);
              }
          }
          else
              continue;
      }
  }
  </code></pre>
  
  <p>If i click on <code>A</code> the toothbrush will show up, except when i click inside <code>B</code>. Here the debug log.</p>
  
  <p><a href="https://i.stack.imgur.com/jDBHp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jDBHp.png" alt="enter image description here"></a></p>
  
  <p>This is the <code>BoxCollider2D</code> A is attached to, which is the <code>*Toothbrush</code> itself together with the <code>dragable.cs</code> script.</p>
  
  <p><a href="https://i.stack.imgur.com/0zOK7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0zOK7.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <p>UPDATE: Thanks to others who answers, the problem become more clearer for me. Below is <code>BoxCollider2D</code> A and <code>BoxCollider2D</code> B. Both of them have script that have most of <code>OnPointerHander</code>. How do i make sure that all <code>OnPointerHandler</code> is triggered on respective <code>BoxCollider2D</code> ?.</p>
  
  <p><a href="https://i.stack.imgur.com/UHiLi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UHiLi.png" alt="enter image description here"></a></p>
  
  <p>Issues that i am having :</p>
  
  <ol>
  <li>OnPointerExit on <code>A</code> is triggered when my pointer enter <code>B</code>.</li>
  <li>if click inside <code>B</code> ,<code>OnPointerDown</code> only triggered on <code>B</code> but not <code>A</code></li>
  </ol>