• Unity
  • Is there a way to release the initial resource

  • Изменено
Related Discussions
...

This is the resource for my spine. In actual operation, I used the Skin.GetRepackedSkin interface for RepackedSkin. After RepackedSkin, it showed that I only referenced a shader and a new texture, but the initial textures in memory , Like the four textures Kamiya, Kamiya2, Kamiya3, Kamiya4 in the picture above, I don't know if there is a way to release them, they take up too much memory,Is it because Kamiya_Atlas is still citing them?

niezhijing написал

I don't know if there is a way to release them, they take up too much memory,Is it because Kamiya_Atlas is still citing them?

Yes, your observations are correct. The textures and materials cannot be released due to the following chain of references:

  1. Your skeleton component (e.g. SkeletonAnimation) references SkeletonDataAsset.

  2. SkeletonDataAsset references SpineAtlasAsset.

  3. SpineAtlasAsset references one or more Materials, one material per original atlas texture.

  4. Each Material references an original atlas Texture.

Now to allow releasing the original atlas textures, you would need to break the chain at any of the above links (e.g. by setting the references to null). If you need the assets again later and re-load them, you could use any of Unity's delayed loading mechanisms instead of direct references, like Addressables, Asset Bundles, Resources, and the like. You would then "manually" handle loading and unloading of these memory-heavy assets.