title: Unity 2D: Check if sprites overlap (c#)
body: <p>I'm making a small matching mini-game in 2D Unity in which players drag and drop different images(sprites) that are in the same category. I have made a drag and drop script that works well, but I am not sure how to go about checking if the images are dropped in the correct place. If the images are matched incorrectly, I want the image that the player had dragged over to transform back to its original spot. If the images are correctly matched, I want both to disappear. How would I check if the images overlap.</p>
  
  <p>Drag and drop script:</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class DragandDrop : MonoBehaviour {
  
  private bool selected;
  
  private void Update()
  {
      //Mouse is held down
     if(selected == true)
      {
          Vector2 cursorPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
          transform.position = new Vector3(cursorPos.x, cursorPos.y, -1.0f);
      } 
  
     //Mouse is released
     if(Input.GetMouseButtonUp(0))
      {
          ScoreScript.scoreValue += 1/6f;
          selected = false;
          //Ignore these:
          // Vector3 position = transform.position;
          // position[2] = 0;
          // transform.position = position;
  
  
          //This is where I think I should check for overlap
      }
  
  }
  
  void OnMouseOver() {
      if(Input.GetMouseButtonDown(0)) {
          selected = true;
      }
  }
  }
  </code></pre>