title: How to make dialogue choices change properly?
body: <p>I've been trying to implement a dialogue system which will let select a choice in a dialogue. Unity shows no errors, dialogue choices are displayed correctly, and yet a weird thing happens - when I press down arrow key (which is supposed to change the selected choice) the othe choices isn't highlighted and is shown just for a second.
  Here is the code for the choice box:</p>
  <pre><code>public class ChoiceBox : MonoBehaviour
  {
      [SerializeField] ChoiceText choiceTextPrefab;
      bool choiceSelected = false;
      List&lt;ChoiceText&gt; choiceTexts;
      int currentChoice;
      public IEnumerator ShowChoices(List&lt;string&gt; choices, Action&lt;int&gt; onChoiceSelected)
      {
          choiceSelected = false;
          currentChoice = 0;
          gameObject.SetActive(true);
          foreach (Transform child in transform)
          {
              Destroy(child.gameObject);
          }
          choiceTexts = new List&lt;ChoiceText&gt;();
          foreach (var choice in choices)
          {
             var choiceTextObj = Instantiate(choiceTextPrefab, transform);
              choiceTextObj.TextField.text = choice;
              choiceTexts.Add(choiceTextObj);
          }
          yield return new WaitUntil(() =&gt; choiceSelected == true);
          onChoiceSelected?.Invoke(currentChoice);
          Debug.Log(&quot;choice is selected&quot;); //this is showing in the console, but the choice box doesn't disappear
          gameObject.SetActive(false);
      }
  
      void Update()
      {
          if (Input.GetKeyDown(KeyCode.DownArrow))
              ++currentChoice;
          else if (Input.GetKeyDown(KeyCode.UpArrow))
              --currentChoice;
          currentChoice = Mathf.Clamp(currentChoice, 0, choiceTexts.Count - 1);
  
          for (int i = 0; i &lt; choiceTexts.Count; i++)
          {
              choiceTexts[i].SetSelected(i == currentChoice);
              
          }
          if (Input.GetKeyDown(KeyCode.Return))
              choiceSelected = true;
      }
  </code></pre>
  <p>Then for the dialogue manager:</p>
  <pre><code>public class DialogueManager : MonoBehaviour
  {
      public Text dialogueName;
      public Text dialogueText;
      public static DialogueManager instance;
      public int activeLineIndex;
      public Animator anim;
      public float typingSpeed = 0.2f;
      public bool canPressE = true;
      public bool makeYourChoice = false;
      List&lt;string&gt; choices = new List&lt;string&gt;();
      List&lt;int&gt; Action = new List&lt;int&gt;();
      public bool dialogueFinished = false;
      [SerializeField] ChoiceBox choiceBox;    
  
      public void EnqueueDialogue(DialogueBase db)
      {
          
          canPressE = false;
          dialogueInfo.Clear();
          foreach(DialogueBase.Info info in db.dialogueInfo)
          {
              dialogueInfo.Enqueue(info);
          }
          anim.SetBool(&quot;isopen&quot;, true);
          DequeueDialogue();
      }
      public void DequeueDialogue()
      {
     
          if (dialogueInfo.Count == 0)
          {
              dialogueFinished = true;
              StartCoroutine(DisplayChoices(choices));
              makeYourChoice = true;
            return;
          }
          if (makeYourChoice)
          {
              EndDialogue();
              return;
          }
          StopAllCoroutines();
          DialogueBase.Info info = dialogueInfo.Dequeue();
          dialogueName.text = info.myName;
          dialogueText.text = info.dialogueText;
          StartCoroutine(TypeText(info));
      }
          public IEnumerator DisplayChoices(List&lt;string&gt; choices = null, Action&lt;int&gt; onChoiceSelected = null)
          {
          if ((choices != null) &amp;&amp; choices.Count &gt; 1)
          {
              yield return choiceBox.ShowChoices(choices, onChoiceSelected);
  
          }
          else
          {
              yield return null;
          }
      }
   
      IEnumerator TypeText(DialogueBase.Info info)
      {
          dialogueText.text = &quot;&quot;;
          foreach (char letter in info.dialogueText.ToCharArray())
          {
  
              yield return new WaitForSeconds(typingSpeed);
              dialogueText.text += letter;
              yield return null;
          }
      }
          void EndDialogue()
          {
              anim.SetBool(&quot;isopen&quot;, false);
          }
          public void GetNextLine()
          {
          if (!canPressE)
          {
              DequeueDialogue();
              Debug.Log(&quot;dalshe&quot;);
          }
          }
          public void Update()
          {
              if (Input.GetKeyDown(KeyCode.Space))
              {
  
                  GetNextLine();
              }
          }
      public Queue&lt;DialogueBase.Info&gt; dialogueInfo;
      public void Start()
      {
          dialogueInfo = new Queue&lt;DialogueBase.Info&gt;();
          canPressE = true;
  
      }
      public void Awake()
              {
                  if (instance != null)
                  {
                      Debug.Log(&quot;fix this&quot; + gameObject.name);
  
                  }
                  else
                  {
                      instance = this;
                  }
              }
          }
  </code></pre>
  <p>For the choice text:</p>
  <pre><code>     public class ChoiceText : MonoBehaviour
      {
  
  Text myText; 
  TextMeshProUGUI choiceText;
  private void Awake()
  {
      choiceText = GetComponent&lt;TextMeshProUGUI&gt;();
  
   
     }
      public void SetSelected(bool selected)
      {
    
          choiceText.color = (selected) ? GlobalSettings.i.HighlightedColor: Color.blue;
      }
  
      public TextMeshProUGUI TextField =&gt; choiceText; 
  
  }
  </code></pre>
  <p>And for the object which the player collides and has a dialogue with:</p>
  <pre><code> if (Input.GetKeyDown(KeyCode.E) )
          {
          onTriggerEnter.Invoke();
          dialogueStarted = true;
          Debug.Log(&quot;запускаем диалог&quot;);
          
      }
      if (dialogueStarted &amp;&amp; dM.dialogueFinished) 
  
  StartCoroutine(ShowDialogueOptions());
        public IEnumerator ShowDialogueOptions()
  {
     int selectedChoice = 1;
      Debug.Log(&quot;show choices&quot;);
      yield return DialogueManager.instance.DisplayChoices(new List&lt;string&gt; { &quot;Yes&quot;, &quot;No&quot; }, (choiceIndex) =&gt; selectedChoice = choiceIndex);
          if(selectedChoice == 0) //&quot;Yes&quot;
          {
              Debug.Log(&quot;Cool&quot;); //this is shown in the console
          }
          else if (selectedChoice == 1) //&quot;No&quot;
          {
              Debug.Log(&quot;You suck&quot;); //this is never shown in the console
          }
  </code></pre>
  <p>Only one choice (&quot;No&quot;) is highlighted with blue, but the other one isn't showing at all. However, when I press down arrow key, it is shown in white colour just for a moment so that it's barely visible. What is shown in the console is marked in comments. Thank you all in advance.</p>