quiz game with background

I want to make a quiz game following unity tutorial. I want to put a background image but i have an error in the gamecontroller script when i put the background.

Here is the error:
NullReferenceException: Object reference not set to an instance of an object
GameController.Start () (at Assets/Scripts/GameController.cs:32)

And the code:

public class GameController : MonoBehaviour {

	public Text questionDisplayText;
	public Text scoreDisplayText;
	public Text timeRemainingDisplayText;
	public 	SimpleObjectPool answerButtonObjectPool;
	public Transform answerButtonParent;
	public GameObject questionDisplay;
	public GameObject roundEndDisplay;


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

	private bool isRoundActive;
	private float timeRemaining;
	private int questionIndex;
	private int playerScore;
	private List<GameObject> answerButtonGameObjects = new List<GameObject> ();

	// Use this for initialization
	void Start () 
	{
		dataController = FindObjectOfType<DataController> ();
		currentRoundData = dataController.GetCurrentRoundData ();
		questionPool = currentRoundData.questions;
		timeRemaining = currentRoundData.timeLimitInSeconds;
		UpdateTimeRemainingDisplay ();
		 
		playerScore = 0;
		questionIndex = 0;

		ShowQuestion ();
		isRoundActive = true;
	}

	private void ShowQuestion()
	{
		RemoveAnswerButtons ();
		QuestionData questionData = questionPool [questionIndex];
		questionDisplayText.text = questionData.questionText;

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

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

  • private 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 ();*
    
  •  }*
    
  •  if (questionPool.Length > questionIndex + 1) {*
    
  •  	questionIndex++;*
    
  •  	ShowQuestion ();*
    
  •  }* 
    
  •  else* 
    
  •  {*
    
  •  	EndRound ();*
    
  •  }*
    
  • }*

  • public void EndRound ()*

  • {*

  •  isRoundActive = false;*
    
  •  questionDisplay.SetActive (false);*
    
  •  roundEndDisplay.SetActive (true);*
    
  • }*

  • public void ReturnToMenu()*

  • {*

  •  SceneManager.LoadScene ("MenuScene");*
    
  • }*

  • private void UpdateTimeRemainingDisplay()*

  • {*

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

  • // Update is called once per frame*

  • void Update ()*

  • {*

  •  if (isRoundActive)*
    
  •  {*
    
  •  	timeRemaining -= Time.deltaTime;*
    
  •  	UpdateTimeRemainingDisplay ();*
    
  •  	if (timeRemaining <= 0f)* 
    
  •  	{*
    
  •  		EndRound ();*
    
  •  	}*
    
  •  }*
    
  • }*
    }

Can you confirm you have a GameObject in the scene with a script called DataController, when this start routine runs?

Try adding a Debug.Log line after dataController = FindObjectOfType (); to make sure dataController is not null after this attempt at a find.

One thing that can cause Find to fail, is if the GameObject is not active, so also make sure that isn’t the case here.

-Larry