title: How to change button image on click Unity
body: <p>I got unlock button for game, it works,but I want to user himself can press button, and then button image change. As you can see in code below when score is >= 10, buttons image change immediately. How can I achieve that?</p>
  
  <pre><code>public GameObject lockBtn;
  Image lockComp;
  public Sprite myLockImage;
  public Sprite myLockSecondImage;
  /////////////////////////////////////////
  
   lockComp = lockBtn.GetComponent&lt;Image&gt; ();
  
          if (bestScore &gt;= 10) {
              lockComp.sprite = myLockImage;
          }
          else
          {
              lockComp.sprite = myLockSecondImage;
          }
  </code></pre>