In 5.2 samples from Platformer PRO (an asset of mine) are crashing the editor when they set the animation override. To make it even more confusing its intermittent (sometimes it occurs instantly on setting the animation override, other times after a second or two).
In the times where the bug isn’t thrown restoring the original animator has no effect (the overriden animations continue to play).
I’m working on extracting a simple repeatable test case but am wondering if anyone had seen this and had any ideas for resolution (or a repeatable test case and bug number I can reference when I contact Unity support).
Code causing the issue:
if (args.OverrideState != null && animationStateOverrideLookup.ContainsKey(args.OverrideState))
{
AnimatorStateInfo info = myAnimator.GetCurrentAnimatorStateInfo(0);
myAnimator.runtimeAnimatorController = animationStateOverrideLookup[args.OverrideState];
if (state != AnimationState.NONE)
{
myAnimator.Play(state.AsString(), 0, info.normalizedTime);
}
}
else if (args.OverrideState == null)
{
AnimatorStateInfo info = myAnimator.GetCurrentAnimatorStateInfo(0);
myAnimator.runtimeAnimatorController = defaultController;
if (state != AnimationState.NONE)
{
myAnimator.Play(state.AsString(), 0, info.normalizedTime);
}
}
If I remove the myAnimator.runtimeAnimatorController = lines then everything works fine (minus no animation override).
Man, I just spent the last couple of hours trying to find out why the editor was crashing, only to find out that I’m also having this exact same problem. The following line for me crashes the editor:
I have not raised a bug as yet, rather busy at the moment. But if no one else has raised one, I’ll do so on the weekend when I have some time to create the test case.
I’ve submitted 2 crashes in one report: Case 726627(nice number :)),with reproes for both. One of the crashes is related to assigning an override controller, which doesn’t have a controller to override.
Both in 5.2.0p1 and 5.2.1 there is this fix:
(722058) - Mecanim: Fixed a crash when setting an Override Controller with no controller to override.
However it doesn’t fix my crash. Is this the fix @Mecanim-Dev mentioned or is there a 5.2.1p1 coming this week with another fix?
I just submitted a bug report which includes a simple project which shows the crash when trying to swap animations at runtime using an override controller in 5.2.1p1:
We have found two incarnation of the same crash. the first one was fixed in 5.2.1p2 and the second one found by @Korindian was fixed this week so it should be available in the next patch release