title: Need a way to use button click functionality vs GetKeyDown in Coroutine
body: <p>This animator script works, however, in place of the Keycode input inside the WHILE LOOP, I need to use a UI button for mobile, which I haven't been able to figure out. I found an answer about putting a wrapper around it to make method available to click event, but have no idea how that's supposed to work within update function. It took me a long time to get this far, being a newbie to unity AND c#, so if you could provide a detailed answer or suggestion, I can get my life back, please help if you can.</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;
  using UnityEngine.Events;
  using SWS;
  
  public class goat_question : MonoBehaviour
  {
      private Animator anim;
      public GameObject player;
      public Text ResultText;
      public Text AnswerText;  
      public Text AnswerText2;
      public Button GoatButton;
  
    
  
      void Start()
      {
          anim = GetComponent&lt;Animator&gt;();
          Button btn = GoatButton.GetComponent&lt;Button&gt;();
          btn.onClick.AddListener(TaskOnClick);
  
      }
  
      void TaskOnClick()
      {
          Debug.Log(&quot;You have clicked the button!&quot;);
      }
     
      // Update is called once per frame
      void Update()
  
      {
          if (AnswerText.text.Equals(AnswerText2.text))
  
          {                                         
  
              StartCoroutine(GoatWalkPathCoroutine());        
  
          }
  
           IEnumerator GoatWalkPathCoroutine()
          {
              while (true)  
              {              
  
                      if (Input.GetKeyDown(KeyCode.K))  
                  {
                      anim.Play(&quot;goat_hi_walk&quot;);
                      player.GetComponent&lt;splineMove&gt;().enabled = true;
                      yield return new WaitForSeconds(27);
                      anim.Play(&quot;goat_hi_licking&quot;);
  
                  }
                  yield return null;
              }
  
          }
  
      }
  
  }
  </code></pre>