hello, in the official Spine tutorial for unity, the MixAndMatchSkinsExample code

I can see they called "AddSkin" several times

every time user change an equipment, they called "AddSkin" several times

I just want to know, if we use the same way as the tutorial, and user keep changing the equipment, will it lead to high memory consumption? since we always call "AddSkin" several times everytime user change an equipment

thanks

Related Discussions
...

Using the AddSkin method multiple times as shown in the Mix and Match example should not lead to high memory consumption. When you call AddSkin, it combines the attachments from the specified skins into a new skin. This process involves updating a dictionary of attachments, which is a lightweight operation. The actual memory consumption comes from the attachments themselves, not from the process of combining them.

However, if you frequently repack skins (i.e., creating new textures from the combined skins), that can lead to higher memory usage and performance overhead. Repacking involves creating new textures and materials, which are more memory-intensive operations.

To manage memory efficiently:

  1. Avoid frequent repacking: Only repack skins when necessary and clear the cache when done using AtlasUtilities.ClearCache.
  2. Reuse skins: Instead of creating new skins every time, reuse existing skins where possible.
  3. On-demand loading: Implement on-demand loading and unloading of skins to manage memory better, as suggested in the Memory management of character with many outfits discussion.

Here is a summary of the key points:

  • Combining skins using AddSkin is lightweight and should not lead to high memory consumption.
  • Frequent repacking of skins can lead to higher memory usage.
  • Implement strategies like on-demand loading and reusing skins to manage memory efficiently.

For more details, you can refer to the spine-unity Mix and Match documentation.