- Изменено
Is there a way to release the initial resource
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:
-
Your skeleton component (e.g.
SkeletonAnimation
) referencesSkeletonDataAsset
. -
SkeletonDataAsset
referencesSpineAtlasAsset
. -
SpineAtlasAsset
references one or moreMaterials
, one material per original atlas texture. -
Each
Material
references an original atlasTexture
.
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.