Sprite animations won't export/run in a published build unless you play in editor first

It’s a strange issue, but I’ve had it from Unity 4.3 and up, including the current 4.6 beta. It’s a 2D game using many sprite animations, but if I just open the project and export a build, the animations won’t play in the build. They just sit there frozen on the first frame. For example, the character is just sliding around. However any animation that has been “viewed” while playing in editor will from that point export fine in published builds. I really can’t trust a published build, and as the game grows it seems crazy that I would have to run through the entire game making sure I’ve “seen” every animation before publishing a build? Is anyone else experiencing this bug?

Same problem here, I can confirm that on Unity 4.5.3. I’m unable to figure out why this happens, but it looks like only objects that start out disabled suffer from this. Also, interestingly, not only does the animation freeze but rather the entire Animator component. I did some debugging and setting Animator parameters (e.g. with SetFloat) and reading them back (GetFloat) doesn’t even return the correct value, which is just frozen.

If you only had a handful of objects you should be able to work around this by making the object transparent or disabling only the sprite renderer, which is what I did for lack of a better solution.

However, if you really have many sprites as you mention, this workaround is kind of infeasible.

It’s not much, but hope that helps, maybe someone will shed light on this soon since it’s a rather serious bug.

UPDATE: From what I could gather, the problem comes down to transitions in Mecanim. For some reason, if you ever add a transition between sprite animation in an animation controller, it will break forever, even if you remove the transition afterwards. So another possible workaround would be not using state transitions ever and handling animations entirely in behavioral scripts. I’ll get to working in a script that makes this a little less painful to manage until it gets fixed.