- Home /
SpriteManager 2: animations invisible on runtime instantiated prefab?
I'm having some trouble getting a normal Sprite (not a packed sprite or managed sprite) to animate in SM2. I'm using a 2x8 sprite sheet of 128x128 sprites. The sprite is instantiated at runtime from a prefab.
If I manually create an instance of the sprite by dragging its prefab to the hierarchy window, the animation plays perfectly. When I instantiate it at runtime, however, it looks fine when it's static, but disappears completely when I animate it. If I tell it to return to static after the animation, it'll disappear for the length of the animation, and then the static sprite will reappear.
When I write the current frame and UVs to the console while the animation is running, it reports the correct frames, but always reports all zeros for the UVs, which makes me think that somehow the runtime instantiated sprite is not being able to access the clips' UV data, but a manually instantiated sprite can.
Can anyone tell me how to fix this? I'll be happy to provide code snippets or any other information.
I have exactly the same problem, except I am using packed sprite with Sprite $$anonymous$$anager 2. $$anonymous$$y prefabs are instantiated at runtime and the animations doesn't seem to play. But if I manually instantiate them before starting the level, the animation works fine. Any idea why this is happening?
Answer by luvcraft · May 26, 2011 at 02:39 PM
I got a solution for this from Brady (creator of SM2). It was a bug in his code, and since he's going to integrate the fix into the next release I won't bother posting it here because it will be outdated as soon as the next version is released.