NullReferenceException

Hi! I keep getting this NullReferenceException. It takes me to the Canvas Quiz. I see everything is referenced so I’m out of ideas. I’ve copied the code exactly from GitLab as a last resort and still nothing. Any ideas? My timer disappears too and I’m not sure what’s going on there.

Thanks!

Hi Moiboi,

Double click on the error message. To which line in your code does it refer?

1 Like

Hi Nina!
Yes, Sorry it keeps pointing to DisplayAnswer’s if statement.

I don’t know how to paste that in fancy like :sweat_smile:

The only nullable variable in that line is currentQuestion. Try to figure out where an object gets assigned to currentQuestion. Use Debug.Logs if necessary to see if something gets assigned during runtime.


See also:

Hi Nina!

So I went back and restarted at the timer lesson and found that what had happened was my On Click () only had selected one button to have Quiz.OnAnswerSelected ! Once I set them all, everything seemed to be working again (though I did catch had indices at [4] that should have only gone to [3].

Glad I didn’t give up though! This was on my mind all day!

log2

Good job on solving this problem, and thanks for sharing your solution! :slight_smile:

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

Privacy & Terms