title: How to call array element that has bool value true unity C#
body: <p>I have four buttons using the same prefab and holding 4 text elements from an array out of which only one is assigned bool value to true. I am trying to access that true element when any of false element is clicked. i want to highlight true element when the false element is clicked. can anyone please help me to achieve this functionality?
  using simpleobjectpool
  taking reference from unity quiz game tutorial
   Thanks </p>
  
  <p>Answer Button Script </p>
  
  <pre><code>public class AnswerButton : MonoBehaviour                                 
  {                           
      public Text answerText;
      private AnswerData answerData;
      private GameController gameController;
      private bool isCorrect;
  
  void Start()
  {
      gameController = FindObjectOfType&lt;GameController&gt;();
  }
  
  public void Setup(AnswerData data)
  {
      answerData = data;
      answerText.text = answerData.answerText;
  }
  
  
  public void HandleClick()
  {
      gameController.AnswerButtonClicked(answerData.isCorrect);
      {
          if (answerData.isCorrect)
          {
  
          }
  
          if (!answerData.isCorrect)
          {
  
  
          }
  
      }
  </code></pre>
  
  <p>Answer Data Script </p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  [System.Serializable]
  public class AnswerData 
  {
      public string answerText;
      public bool isCorrect;
  }
  </code></pre>
  
  <p>QuestionData Script</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  [System.Serializable]
  public class QuestionData
  {
  
     public string questionText;
     public AnswerData[] answers;
  }
  </code></pre>
  
  <p>Game Controller Script</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;
  using UnityEngine.SceneManagement;
  using System;
  
  public class GameController : MonoBehaviour
   {
     public Text questionText;
     public Text scoreDisplayText;
     public SimpleObjectPool answerButtonObjectPool;
     public Transform answerButtonParent;
     public GameObject questionPanel;
     public GameObject roundOverPanel;
     public GameObject levelsPanel;
     private DataController dataController; 
     private RoundData currentRoundData;
  
     private bool isRoundActive;
     private float timeBeetweenQuestions = 3.0f;
  
     private List&lt;GameObject&gt; answerButtonGameObjects = new List&lt;GameObject&gt;();
  
     private QuestionData[] questionPool;
     private int questionIndex;
     private int qNumber = 0;
     private List&lt;int&gt; questionIndexesChosen = new List&lt;int&gt;();
     public int playerScore = 0;
     public int totalQuestions;
  
  
     private static int pointAddedForCorrectAnswer;
  
     public AudioSource answerButtonClicked;
     public AudioSource wrongAnswerClicked;
  
  
     void Start ()
     {
              dataController = FindObjectOfType&lt;DataController&gt;();
              currentRoundData = dataController.GetCurrentRoundData();
              questionPool = currentRoundData.questions;
  
              playerScore = 0;
              questionIndex = 0;
              scoreDisplayText.text = "Score: " + playerScore.ToString();
              isRoundActive = true;
              ShowQuestion();
     }
  
  
  
     private void ShowQuestion()
     {
              RemoveAnswerButtons();
  
              QuestionData questionData = questionPool[questionIndex];
              questionText.text = questionData.questionText;
  
              for (int i = 0; i &lt; questionData.answers.Length; i++)
              {
  
  
            GameObject answerButtonGameObject = 
            answerButtonObjectPool.GetObject();   
  
            answerButtonGameObjects.Add(answerButtonGameObject);
  
            answerButtonGameObject.transform.SetParent(answerButtonParent);
  
            AnswerButton answerButton = 
           answerButtonGameObject.GetComponent&lt;AnswerButton&gt;();
           AnswerButton.Setup(questionData.answers[i]);
  
          }
   }
  
   private void RemoveAnswerButtons()
   {
       while (answerButtonGameObjects.Count &gt; 0)
       {
  
             answerButtonObjectPool.ReturnObject(answerButtonGameObjects[0]);
             answerButtonGameObjects.RemoveAt(0);
       }
   }
  
   IEnumerator TransitionToNextQuestion()
  
   {
          yield return new WaitForSeconds(timeBeetweenQuestions);
          ShowQuestion();
   }
  
   IEnumerator WaitForFewSeconds()
  
   {
          yield return new WaitForSeconds(timeBeetweenQuestions);
          EndRound();
   }
      IEnumerator ReturnCorrectButtonColor()
  {
      Debug.Log("im correct");
      GetComponent&lt;Button&gt;().image.color = Color.green;
      yield return new WaitForSeconds(seconds: 2.9f);
      GetComponent&lt;Button&gt;().image.color = Color.white;
  
  }
  
  IEnumerator ReturnWrongButtonColor()
  {
      Debug.Log("im wrong");
      GetComponent&lt;Button&gt;().image.color = Color.red;
      yield return new WaitForSeconds(seconds: 2.9f);
      GetComponent&lt;Button&gt;().image.color = Color.white;
  
  }
  
  public void AnswerButtonClicked (bool isCorrect)
  
  {
     if (isCorrect)
      {
          playerScore += currentRoundData.pointAddedForCorrectAnswer;
          scoreDisplayText.text = "Score: " + playerScore.ToString();
  
          //play coorect answer sound
          answerButtonClicked.Play();
          StartCoroutine(ReturnCorrectButtonColor());
      }
  
      if (!isCorrect)
      {
          //play wrong answer sound 
          answerButtonClicked = wrongAnswerClicked;
          answerButtonClicked.Play();
          StartCoroutine(ReturnWrongButtonColor());
          //     buttons = GameObject.FindGameObjectsWithTag("Answer");
  
         //    {
        //    foreach (GameObject button in buttons)
       //    {
       //        if (button.GetComponent&lt;AnswerButton&gt;     
       //().answerData.isCorrect)
      //        {
     //            button.GetComponent&lt;AnswerButton&gt; 
     //  ().StartCoroutine(ReturnCorrectButtonColor());
     //        }
    //    }
  //}
      }
  
  
          if (qNumber &lt; questionPool.Length - 1)   /
          {
                qNumber++;
                StartCoroutine(TransitionToNextQuestion());
  
          }
          else
          {
  
                StartCoroutine(WaitForFewSeconds());
          }
  }
  
          public void EndRound()
          {
               isRoundActive = false;
               questionPanel.SetActive(false);
               roundOverPanel.SetActive(true);
  
          }
  
         //on  button click return to main menu
         public void ReturnToMenu ()
         {
            SceneManager.LoadScene("MenuScreen");
         }
  
  
  
   }
  </code></pre>