Answer the question
In order to leave comments, you need to log in
Why does the console throw a NullReferenceException in this case?
The console throws an error when the game ends. "Object instance reference not set." It swears at this piece of code:
public void OnDestroy()
{
if (Application.isPlaying)
{
InputManager.instance.RemoveWeapons(this);
}
}
if (Application.isPlaying) { }
Debug.Log(Application.isPlaying);
Answer the question
In order to leave comments, you need to log in
The point is exactly that you have something equal to null.
What exactly - the debugger will show, but 99% that this is an instance of the InputManager.
scene deactivation has nothing to do with this property. Read the manual.
To solve the problem, there are two options:
- check instance for null
- reconsider the architecture so that there are no such calls.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question