Null Reference exception problem on quiz

I followed the instructions for the quiz game, but for whatever reason, the Game Manager object could not find the objects using FindObjectofType and gave me a null reference exception for gameObject.SetActive fxns saying that they were not set to an instance of the object.

However, when I serialized those objects and just dragged them in from the editor, I was able to run the program without a hitch. Any ideas for the reason this could be?

Welcome to the community @Ju_Ten

It is difficult to tell what the problem is without seeing what the code looks like where the error occurs. Could you possible share the code?

Hi @Ju_Ten,

Welcome to our community! :slight_smile:

FindObjectOfType returns an active object in the Hierarchy. Maybe the object your code is looking for is inactive in that moment. Also make sure that all method names are spelt correctly, especially the Unity methods. For example, start() and Start() are treated as two different methods in C#.

If that did not help you solve the problem, have you already tried to add Debug.Logs to your code to see what is going on during runtime?


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms