Spammed with a Null Reference exception in Animator
Asked Answered
C

10

0

I don’t know how to track down what asset is missing… this is an editor error, not an in-game issue.

Works fine in-game.

However, my game started taking 20-50 seconds to load after this error began:

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.AnimationStateMachine.TransitionEditionContext.BuildNames () (at C:/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/AnimationStateMachine/TransitionEditionContext.cs:44)
UnityEditor.Graphs.AnimationStateMachine.TransitionEditionContext..ctor (UnityEditor.Animations.AnimatorTransitionBase aTransition, UnityEditor.Animations.AnimatorState aSourceState, UnityEditor.Animations.AnimatorStateMachine aSourceStateMachine, UnityEditor.Animations.AnimatorStateMachine aOwnerStateMachine) (at C:/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/AnimationStateMachine/TransitionEditionContext.cs:28)
UnityEditor.Graphs.AnimationStateMachine.AnimatorTransitionInspectorBase.ComputeTransitionContexts () (at C:/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/AnimationStateMachine/AnimatorTransitionInspectorBase.cs:125)
UnityEditor.Graphs.AnimationStateMachine.AnimatorTransitionInspectorBase.OnEnable () (at C:/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/AnimationStateMachine/AnimatorTransitionInspectorBase.cs:87)
UnityEditor.Graphs.AnimationStateMachine.AnimatorStateTransitionInspector.OnEnable () (at C:/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/AnimationStateMachine/AnimatorStateTransitionInspector.cs:55)
Capable answered 8/1 at 21:45 Comment(5)

A lot of Editor errors can be ignored. The editor happens to get some stuff set funny, sprays some errors, tries again and figures it out. Of course, these particular errors might mean something, not sure.

Orthographize

If the game load time didn't dramatically slow down at the same time these errors started, I would agree!

Capable

I have the same problem. It popped up when I started trying to manually play animations in my animator controller via scripting. I have no idea what's causing it.

Amand

I have same problem too, it's a rare case, but showing the animator tab looks like solving the problem, and when I relaunch Unity, this error never popping again.

Scourge

anybody knows the permanent solution for this so far?

Scourge
P
0

NullReferenceException means the object referenced doesn’t exist. It’s not exclusive to scripting. If you deleted the actual animation file from your object you’ll have to reload the object.

or

in my case I copied a gameobject whose have a animator Controller,
for solving I just again assigned a controller in animator(inspector), thats resolve my error.
hope this will help you

Practicable answered 3/2 at 9:49 Comment(0)
L
0

it also happened to me when I was adding extra animation states and then I removed them, just followed Wildan suggestion to close Unity and reopen it again and that fixed it for me

Lemcke answered 6/6, 2023 at 2:21 Comment(0)
D
0

Actually I noticed that when changing my “has exit time” checkbox in an animation state, my FindGameObjectWithTag(“Player”) script references will no longer work. You have to restart it to recompile everything correctly. An interesting situation since everything works fine otherwise. I just wonder if you were altering animation states when this happened.

Dickdicken answered 6/6, 2023 at 1:47 Comment(0)
I
0

I got same error . But i fixed that deleting all meta files in assets folder/subfolder inside. If unity running close unity and after delete (meta files). Its must work .

Insufferable answered 6/6, 2023 at 2:8 Comment(0)
P
0

It’s a bug. Restart Editor

Prospective answered 23/3 at 23:13 Comment(1)

This worked! Thank you!

Maidenhood
R
0

This is caused by having an animation state of length 0 somewhere. The unity code divides by animation length in lots of places, assuming that this value will always be > 0.

This causes various bugs throughout the editor (like difference in effective lengths classic).

A restart will temporarily fix this particular bug, or making sure all animations / states have an exit time > 0 set will resolve it permanently. At least until the Unity devs decide to go through the code and put if (!= 0) before each instance of / length.

Retribution answered 5/12, 2017 at 18:17 Comment(0)
C
0

just close the Animator window and open it up again

Confirmation answered 21/2, 2018 at 7:15 Comment(1)

Saving will probably have the same effect.

Matrona
S
0

This has happened to me before out of nowhere – I don’t know when exactly it started with the project. Closing and reopening the project fixed it automatically.

Satinet answered 19/3, 2018 at 3:0 Comment(0)
A
0

For me the bug rises each time I had the GameObject selected in the editor’s scene. When I select anything else or nothing the error doesn’t appear anymore…

Archenteron answered 11/9, 2018 at 15:46 Comment(0)
P
0

I thought I was doomed (Unity version 2022.3.16f1) but in fact, just closing (terminating!) the Animator tab and opening it again with Window → Animation → Animator fixed the problem. I think this all went wrong when I renamed an animation. Why does Animator break under so many trivial circumstances? That’s the real question.

Pascale answered 8/1 at 11:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.