Possible solution for NullReferenceException error

Atleas in my case, the error was caused by removing the [SerializeField] from the currentQuestion variable.
Removing the field in the inspector give to the variable a null value, thats causing the error when the game starts, because it’s value it is setting up after the GetRandomQuestion method is called, and thats is located in the update method.
So to fix it, i’ve just added back the [SerializeField] and reassigned back the Scriptable object in the inspector at the currentQuestion variable, hoping it will not mess up stuff later, but that’s will be probably a story for next time.
Hope i helped someone struggling with the same error.

2 Likes

Privacy & Terms