Search Issue Tracker
Won't Fix
Won't Fix in 5.5.X, 5.6.X
Votes
0
Found in
5.5.2p2
Issue ID
900616
Regression
No
[Animation] RuntimeAnimatorController becomes not valid when instantiated from AssetBundle in Editor
To reproduce:
1) Open attached project "AnimatorControllerBundle.zip".
2) Rebuild bundles using `Test/Build Bundles` in menu bar.
3) Open Main Scene and enter Play Mode.
4) Click 1 to load and instantiate from Resources folder (works).
5) Click 2 to load and use directly from AssetBundle (works).
6) Click 3 to load and instantiate from AssetBundle (broken, prints warning to console).
Expected result: Instantiated RedAnimBox(Clone) works, and animation is played.
Actual result: Animation is not playing and warning message is given:
The Animator Controller (RedAnimBox(Clone)) you have used is not valid. Animations will not play
UnityEngine.Animator:set_runtimeAnimatorController(RuntimeAnimatorController)
Reproducible: 5.3.7p1, 5.4.5p1, 5.5.3f1, 5.6.0f3, 2017.1.0b1
Notes:
No warnings in 5.3.7p1 but it still doesn't work.
Works fine in standalone build.
NOTE: there is really no point in instantiating AnimatorControllers from AssetBundles because when a controller is bundled, there is no way to edit it further. In addition to that, AnimatorController is an asset, there are no instances of it in the scene, the Animator simply keeps references to it.
The right thing to do is to load and use it directly from an AssetBundle.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
wuGor
Aug 05, 2020 03:35
Finally! i figure out the problem. First, it only cause on Editor. When Editor lose focus an get focus again, the unity "totalAllocateMemory" suddenly became lower. Then we load AssetBundle and Instantiate an gameobject which have animator on it.And we get the warning:Animator is not playing an animation controller. Animations is missing!
The way to solve this proble: Editor->Preferences->General->Script Changes While Playing set to "Recompile After Finished Playing"
wuGor
Aug 05, 2020 02:16
And this error wont cause in 2019.1.10f1. And it is very easy to reproduce when i unload assetbundle and reload assetbundle.
wuGor
Aug 05, 2020 02:01
I have the same issue. I'm on 2019.4.5f1. Like ILYES-GARIFULLIN say:sometimes everything works fine, and sometimes when calling Instantiate(), all the prefabs from the AssetBundle cause this error.
rgarlik
Aug 04, 2020 08:34
I think I found a workaround:
Every object I'm instantiating has a script attached to itself that copies the AnimationController from said object and then re-attaches it with a slight delay.
This seems to have fixed it.
Example implementation:
private RuntimeAnimatorController _animatorController;
void Start() {
_animatorController = GetComponent<Animator>().runtimeAnimatorController;
GetComponent<Animator>().runtimeAnimatorController = null;
StartCoroutine(_reloadStoryObjects());
}
private IEnumerator _reloadStoryObjects()
{
yield return new WaitForSeconds(0.2f);
_animatorControllers.runtimeAnimatorController = _animatorController;
}
rgarlik
Jul 20, 2020 15:41
Similiar problem here. Seems like the bug was fixed for a while and now people are stumbling upon it again. I'm on 2019.3.0f6
Pelicapp
May 09, 2020 14:21
Same problem here and like Ilyes-Garifullin said it does not appear every time. Very strange.
dnomn8r
Apr 23, 2020 01:43
I have a workaround that "seems" to work.
Instead of just simply setting the runtimeoverride controller, I create a new one and copy the animation pair data over.
public static void DeepCloneAnimatorOverride(Animator animator, RuntimeAnimatorController originalOverrideController) {
AnimatorOverrideController newAnimatorOverride = new AnimatorOverrideController(originalOverrideController);
List<KeyValuePair<AnimationClip, AnimationClip>> pairs = new List<KeyValuePair<AnimationClip, AnimationClip>>();
for (int i = 0; i < newAnimatorOverride.animationClips.Length; ++i) {
pairs.Add(new KeyValuePair<AnimationClip, AnimationClip>(newAnimatorOverride.animationClips[i], originalOverrideController.animationClips[i]));
}
newAnimatorOverride.ApplyOverrides(pairs);
animator.runtimeAnimatorController = newAnimatorOverride;
}
ilyes-garifullin
Apr 12, 2020 09:25
And the most interesting thing about this bug is that it doesn't appear every time the game starts, sometimes everything works fine, and sometimes when calling Instantiate(), all the prefabs from the AssetBundle cause this error.
ilyes-garifullin
Apr 12, 2020 09:19
I have the same issue, and I'm not playing the animation before my model is instantiated. This warning throws when I'm instantiating my prefab from assetbundle.
Arvin6
Aug 29, 2017 05:35
You are playing the animation before your model is instantiated. I had this issue before, try moving your Animator trigger after instantiate of your model.