• Unity
  • Best way to pool Spine gameObjects

Hello,

I was playing with “Instantiate from Script” scene and I was looking the implementation details.

If you have a game that has a small amount of enemies you can pool them by instantiate/deactivate and use them when needed.

Now if you have a variety of enemies I was wandering, if there is a way to create a number of “generic” SkeletonAnimation gameObjects and dynamically assign the AltasAsset and SkeletonDataAsset (without creating a NewSkeletonAnimationGameObject like in DataAssetsFromExportsExample class).

Thank you.

Related Discussions
...

If enemy variations share the same SkeletonData (same Spine skeleton and project) and are just a matter of changing skins or swapping out attachments, you can pool a bunch of SkeletonAnimations and then just change their skin as needed when you obtain instances from the pool.

If you are pooling SkeletonAnimations, set skeletonAnimation.clearStateOnDisable to true. This prevents previous animations and poses from persisting when you recycle instances from the pool.

Otherwise, pooling doesn't really help much. If you swap out a SkeletonAnimation's SkeletonData asset, it needs to reinitialize and orphan old objects and allocate memory for new ones.

I see! 🙂

Thank you very much for the quick answer.