title: How to make a sprite clickable?
body: <p>I have googled plenty and only come up with really complicated methods of doing it. I also found the function <a href="http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseDown.html" rel="nofollow noreferrer">OnMouseDown()</a> but I haven't been able to make it work.</p>
  <p>At the moment the sprite activates when you tap anywhere on screen.</p>
  <p><strong>EDIT</strong> - Yes it has a 2d Box collider</p>
  <p>My code below:</p>
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class mute : MonoBehaviour 
  {
      public bool isMuted = false;
      public Sprite mute1, mute2;
  
      private SpriteRenderer spriteRenderer; 
  
      private void Start () 
      {
          spriteRenderer = GetComponent&lt;SpriteRenderer&gt;();
  
          if (spriteRenderer.sprite == null) 
              spriteRenderer.sprite = mute1;
      }
      private void Update () 
      {
          if (Input.GetKeyDown (KeyCode.Mouse0)) 
          {
              if (!isMuted)
              {
                  AudioListener.pause = true;
                  AudioListener.volume = 0;
  
                  isMuted = true;
                  ChangeSprite();
  
              }
              else
              {
                  AudioListener.pause = false;
                  AudioListener.volume = 1;
  
                  isMuted = false;
                  ChangeSprite();
              }
          }
      }
      private void ChangeSprite() =&gt; spriteRenderer.sprite = 
  </code></pre>
  <p>spriteRenderer.sprite == mute1 ? mute2 : mute1;
  }</p>