- Home /
2d sprite animator - Invalid Layer Index
I've made 2d game using 2d sprite renderer, animator.
I've been set my animator as following image
Then save as prefab to instantiate later by code like
GameObject character = (GameObject)Instantiate(prefabArray[i]);
Then when I want this character to play any animation I use code like
myAnimator.Play("idle");
Everything works well when I test on editor, problem occurs when I build to iOS/Android.
Its said "Invalid Layer Index" and my character can't play any animation, it's occur to last character in my prefab array and it's not always occurred it's occur on some build (so I've to rebuild it again to fix this), I think it's might be Unity's bug (because it's occur sometime) so there are any solution to prevent this?
Same kind of problem. I instantiate gameobject and at Start() I try to play manually some animation. Occured maybe after 4.5 patch. Works well on editor (have got error in editor only once) but do that in phone (WP8) all the time.
Answer by psyydack · Jun 11, 2014 at 02:20 PM
It's an Unity Bug : http://forum.unity3d.com/threads/editor-sporadically-forgets-about-a-mecanim-state-machine.203406/
Restarting the editor and rebuilding to devices fixes the issue, only to have it come back once in a while.
Is there a case number for this ? This screwed us now (released a bad build due to this)
Your answer

Follow this Question
Related Questions
Setting animator parameter on a single instance of a prefab sets the parameter for all instances 3 Answers
Runtime instantiated prefab doesn't animate 3 Answers
All calls to Resources.Load stopped working on Amazon devices (Unity 5.6.3p3) 1 Answer
Controlling Animator through Script. I'm stuck please help! 0 Answers
spawns without controller-: Object reference not set to an instance of an object--but i swear it is! 1 Answer