[Solved]unexplanable null refrence exception
so i was working with animation for the first time today using it to animate part of a (4.5) UI. and at one point (really not sure when) i started getting this nullref error. it doesn't seem to do anything...but its there and it worries me that it could be hurting something in the background. i have no scripts for this animation its 100% done with the editor (animation editor and the animation node editor) heres the stack trace. maybe someone can help me figure out what's causing it so i can put a stop to it
(p.s. : i completely removed the animation controller from the game object and this was still happening so i really don't know right now why this is a thing)
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:58)
Answer by ackley14 · Aug 02, 2015 at 11:23 PM
Had to restart unity! thanks to zach.r.d and Positive7 for the tip!!!
There has to be a better way.. restarting Unity sucks. I have to restart each time I make a tiny change in the animator..
Add a transition --> Animator crashes to spam null refrence exception Turn off Has Exit Time --> Animator crashes to spam null refrence exception Add a Condition --> Animator crashes to spam null refrence exception etc etc :( :( :( :(
Had the same problem after referencing the animator in code. Thought it was something in the code at first. Bit annoying, going to restart next time!
Hey I know this is an old thread, but it's still the top result for this issue. Just wanted to note that this is still happening in Unity 2018.2.0f2.
In this version closing and reopening the animator and animation tabs fixes this.
I just got this error in 2017.3.1f1 when I hit the "play" button in the "Game" tab (everything was reacting on a big delay afterwards), even though I don't use any animations.
Answer by lojack84 · Nov 19, 2018 at 11:08 PM
Yeah try restarting Unity. Sonewhat inexplicable null reference voids occur in 4.5. These do not persist after the game is compiled.
This does not work, or rather it works for about twenty $$anonymous$$utes. unity version: 2019.2.17.f1
Answer by Manish_kunwar · Mar 07, 2021 at 08:53 AM
just save your current layout, it should solve your error,
Oh my god, I can't believe this solved the problem! I was getting these annoying error messeges as well, but now to think of it, I really forgot the layout to be saved. By the way, I am using 2021.1.15f1 Thanks ^^
Answer by SuperCool83 · Sep 05, 2017 at 03:12 PM
I found my Animation Play, Pause and Next Frame buttons were Red suggesting the animation was still trying to record key frames. Once I turned these off (by pressing the red play button again - the one that normally enters the play game mode) I was able to continue as before.