title: Stop a raycast from going through the UI button
body: <p>How do I stop a RayCast from going through a UI Button and hitting the collider behind the button?</p>
  
  <p>Some things I tried:</p>
  
  <ul>
  <li>The collider covers the entire view, but it is located on (0,0,2)</li>
  <li>The button is on (0,0,-5), so in front of the collider from the camera's point of view.</li>
  <li>I noticed a Graphic Raycaster component on the Canvas and I set that to Blocking Objects: All, Blocking Mask: Everything, and Ignore Reverse Graphics: True (true by default)</li>
  </ul>
  
  <p>So every time I click the button, it executes the event, but my player ends up behind the button, because the RayCast also hit the other collider, behind the button.</p>
  
  <pre><code>void Start(){
      touchControl = LayerMask.GetMask("TouchControl");
  }
  
  // Update is called once per frame
  void Update () {
  
      if (Input.GetMouseButton(0))
      {
          RaycastHit hit;
          Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
          if (Physics.Raycast(ray, out hit, 100, touchControl))
          {
              Destroy(GameObject.FindGameObjectWithTag("Destination"));
              CalculatedDestination = Instantiate(Destination, hit.point, Quaternion.identity);
          }
      }}
  </code></pre>