Why, when I delete transitions from the Animator State Machine, do I get a null reference exception?

After I have edited my animation state machine in the Animator Controller, I often get the following bug when playing my game. I think it is related to me deleting transitions from the animation state machine, but I can not get the bug to go away.

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.AnimationStateMachine.TransitionInspector.OnEnable () (at /Applications/buildAgent/work/812c4f5049264fad/Editor/Graphs/UnityEditor.Graphs/AnimationStateMachine/TransitionInspector.cs:70)

Thanks!

I was getting this issue as well. I tried removing the Animation Controllers and recreating them (without ever creating any transitions). I applied the new controllers to my characters, but was still seeing this error.

What finally resolved it was to save my file, shut down Unity and then relaunch it. It seems the reference was cached in the IDE, and restarting allowed it to be cleared.

The line:

animator = GetComponent();

Is your problem. The “GetComponent” call requires a component type to get. For example:

animator = GetComponent(Animator);

What I did was I delete all the metadata in the assets folder library/metadata. That problem triggers when I untick the animator exit time, it throws the nullreferenceexception, I found restarting is a solution but the better way is deleting the metadata and then poof! The bug is gone.