having a problem with object pooling.

hey guys i am currently making a quiz game for our thesis. we were using the given object pooling at unity tutorial. and some of the features are working but. i am having a problem because i cant show the panel when the button clicked was correct. an the only panel which is showing is the wrongDisplay(Panel). and if I clicked the button on the wrongDisplay(Panel) my program hangs. which supposed to get back at the questionPanel to the other randomly picked question. can somebody help us because there’s only two weeks before our final defense. thank you.

here’s the code:

Code(CSharp):

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Collections.Generic;

public class GameController : MonoBehaviour {

public Text questionDisplayText;
public Text ScoreDisplayText;
public Text TimeRemainingDisplayText;
public Text imageQuestionDisplayText;

public SimpleObjectPool answerButtonObjectPool;

public Transform answerButtonParent;

public GameObject questionDisplay;
public GameObject WrongDisplay;
public GameObject timesUpDisplay;
public GameObject GameOverDisplay;
public GameObject CorrectDisplay;
public GameObject pauseButton, pausePanel;

private DataController dataController;
private RoundData currentRoundData;
private QuestionData[] questionPool;

private bool isRoundActive;

private float timeRemaining;
private int questionIndex;	
private int playerScore;
private int qNumber = 0;

private List <GameObject> answerButtonGameObjects = new List<GameObject> ();
private List <int>  questionIndexesChosen = new List <int>();
// Use this for initialization

[SerializeField]
private float timeBetweenQuestions = 0 ;

void Start ()
{
	dataController = FindObjectOfType<DataController> ();
	currentRoundData = dataController.GetCurrentRoundData ();
	questionPool = currentRoundData.questions;
	timeRemaining = currentRoundData.timelimitInSeconds;
	UpdateTimeRemaining ();

	playerScore = 0;
	questionIndex = 0;

	ShowQuestion ();
	QuestionData questionData = questionPool [questionIndex];
	questionDisplayText.text = questionData.questionText;
	pausePanel.SetActive (false);

	health = hearts.Length;
	print (health);

	isRoundActive = true;

}

public void OnPause()
{
	pausePanel.SetActive (true);
	pauseButton.SetActive (false);
	Time.timeScale = 0;

}
public void OnUnPause()
{
	pausePanel.SetActive (false);
	pauseButton.SetActive (true);
	Time.timeScale = 1;

}
public void ShowQuestion()
{
	RemoveAnswerButtons ();

	ChooseQuestion ();
	QuestionData questionData = questionPool [questionIndex];
	questionDisplayText.text = questionData.questionText;
	if (questionDisplayText.text != null) {
		questionDisplay.SetActive (true);
	}
	else
	{
		questionDisplay.SetActive (false);
	
	}

	for (int i = 0; i < questionData.answers.Length; i++) 
	{
		GameObject answerButtonGameObject = answerButtonObjectPool.GetObject ();
		answerButtonGameObject.transform.SetParent (answerButtonParent);
		answerButtonGameObjects.Add (answerButtonGameObject);

			AnswerButton answerButton = answerButtonGameObject.GetComponent<AnswerButton> ();
		answerButton.Setup (questionData.answers *);*
  •   }*
    
  •   questionDisplayText.text = questionData.questionText;*
    
  • }*

  • void ChooseQuestion()*

  • {*

  •   bool questionChosen = false;*
    
  •   while (questionChosen != true)* 
    
  •   {*
    
  •   	int random = Random.Range (0,questionPool.Length);*
    
  •   	if (!questionIndexesChosen.Contains (random))* 
    
  •   	{*
    
  •   		questionIndexesChosen.Add (random);*
    
  •   		questionIndex = random;*
    
  •   		questionChosen = true;*
    
  •   	}*
    
  •   }*
    
  • }*

  • public void RemoveAnswerButtons()*

  • {*

  •   while (answerButtonGameObjects.Count > 0)*
    
  •   {*
    
  •   	answerButtonObjectPool.ReturnObject (answerButtonGameObjects[0]);*
    
  •   	answerButtonGameObjects.RemoveAt (0);*
    
  •   }*
    
  • }*

  • public void AnswerButtonClicked(bool isCorrect)*

  • {*

  •   if (isCorrect) {*
    
  •   	playerScore += currentRoundData.pointsAddedForCorrectAnswer;*
    
  •   	ScoreDisplayText.text = "Score: " + playerScore.ToString ();*
    
  •   	CorrectDisplay.SetActive (true);*
    
  •   	questionDisplay.SetActive (false);*
    
  •   	StartCoroutine (TimeBetweenQuestions ());*
    
  •   }* 
    
  •   if(!isCorrect)*
    
  •   {*
    
  •   	WrongDisplay.SetActive (true);*
    
  •   	questionDisplay.SetActive (false);*
    
  •   	StartCoroutine (TimeBetweenQuestions ());*
    
  •   	Time.timeScale = 0;*
    
  •   }*
    
  •   if (health == 0)* 
    
  •   {*
    
  •   	EndRound ();*
    
  •   }*
    
  •   if (qNumber + 1 < questionPool.Length)*
    
  •   {*
    
  •   	qNumber++;*
    
  •   	ShowQuestion ();*
    
  •   }*
    
  •    else*
    
  •   {*
    
  •   	EndRound ();*
    
  •   }*
    
  • }*

  • public void EndRound()*

  • {*

  •   questionDisplay.SetActive (false);*
    
  •   GameOverDisplay.SetActive (true);*
    
  •   StartCoroutine (TimeBetweenQuestions ());*
    
  •   Time.timeScale = 0;*
    
  • }*

  • public void ReturnToQuestionPanel ()*

  • {*

  •   questionDisplay.SetActive (true);*
    
  •   ShowQuestion ();*
    
  •   UpdateTimeRemaining ();*
    
  •   StartCoroutine (TimeBetweenQuestions ());*
    
  • }*

  • IEnumerator TimeBetweenQuestions()*

  • {*

  •   yield return new WaitForSeconds (timeBetweenQuestions);*
    
  •   CorrectDisplay.SetActive (false);*
    
  •   WrongDisplay.SetActive (false);*
    
  •   timeRemaining = 15;*
    
  •   QuestionData questionData = questionPool [questionIndex];*
    
  •   questionDisplayText.text = questionData.questionText;*
    
  • }*

  • private void UpdateTimeRemaining()*

  • {*

  •   TimeRemainingDisplayText.text = "Time: " + Mathf.Round (timeRemaining).ToString ();*
    
  • }*

  • // Update is called once per frame*

  • void Update () {*

  •   if (isRoundActive)* 
    
  •   {*
    
  •   	timeRemaining -= Time.deltaTime;*
    
  •   	UpdateTimeRemaining ();*
    
  •   }*
    
  •   if (timeRemaining <= 0f)* 
    
  •   {*
    
  •   	qNumber++;*
    
  •   	ShowQuestion ();*
    
  •   	timeRemaining = 15;*
    
  •   	timesUpRound ();*
    
  •   }*
    
  • }*

  • private void timesUpRound()*

  • {*

  •   questionDisplay.SetActive (false);*
    
  •   timesUpDisplay.SetActive (true);*
    
  • }*
    }

hi;

well that’s a huge code right there ;

did u write it all by your self ?

I mean if so then u should not have some problem like this ;

i cant underestand your question and the relation to the script ;

if u can not solve the problem and runing out of time send to my gmail some screen shot of your project so i can help u
savajjad@gmail.com

@Cuttlas-U
my problem is that when i picked the correct answer, the correct answer panel didn’t show up instead the wrong display panel shows. and if I click the button that will return to the question display our program hang up. and didn’t return to the question panel that will shows the other randomly pick question.