To address your concerns about optimizing memory and draw calls by using Unity's regular sprites internally for drawing in Spine, here are some insights and potential solutions based on the current capabilities and limitations of Spine and Unity integration:
Repacking Atlases: You can repack atlases at runtime to combine multiple textures into a single atlas, which can help reduce draw calls. This is demonstrated in the Spine Examples/Other Examples/Mix and Match and Mix and Match Equip example scenes. This approach can help in reducing the number of draw calls by ensuring that all images are packed into a single shared atlas.
Using Unity's SpriteAtlas: While Spine does support using Unity's SpriteAtlas as an atlas provider, it is generally recommended to use Spine's own texture packing for better performance and fewer issues. However, if you need to use Unity's SpriteAtlas, you can follow the steps outlined in the spine-unity documentation to set it up. Note that this might still result in some performance overhead due to the way Unity handles SpriteAtlases.
Custom AttachmentLoader: If you need more control over how sprites are loaded and used, you can write your own
AttachmentLoader
and pass it to theSkeletonJson
orSkeletonBinary
constructors. This allows you to import from any atlas format and potentially integrate more closely with Unity's sprite handling.Batching and Draw Calls: To improve batching and reduce draw calls, ensure that all your sprites are packed into a single atlas and that dynamic batching requirements are met. This includes keeping the vertex count low and ensuring that materials and textures are shared across sprites.
Addressables and Late Binding: Using Unity's Addressables system can help manage memory and loading times, especially for large projects. By referencing sprites without forcing their textures to be included in the build, you can load and bind them later, which can help optimize memory usage.
Performance Considerations: For mobile games, it's crucial to optimize both memory usage and draw calls. Using a single larger atlas texture shared between multiple skeletons can help. Additionally, consider runtime repacking to combine skins or attachments from multiple atlas textures into a single texture.
For more detailed steps and examples, you can refer to the following resources:
By leveraging these techniques, you can optimize your game's performance while using Spine for animations.