Hey!
I'm currently working on a game based on hundreds of cards (look like polaroid pictures).
Screenshot:

The foreground (vulture) and background (recording studio) are both Spine Skeletons. We want the photos to animate.
The problem is:
We have a lot of characters and backgrounds for the pictures so we need to load and unload them because of memory management. Some of them have got pretty big atlases.
When the background is an static image file I can use:
Texture2D texture;
void LoadTexture() {
texture = Resources.Load<Texture2D>("Art/Backgrounds/Spine/garage/garageHD");
}
void UnloadTexture() {
Resources.UnloadAsset(texture);
}
Everything works fine. The textures are properly loading and unloading from memory.
I would like to use similar code for Spine Skeletons. I created this one:
private GameObject createdSkeletonObject;
void LoadSkeleton() {
var skeletonDataAsset = Resources.Load<SkeletonDataAsset>("Art/Backgrounds/Spine/studio/studio_SkeletonData");
var newSkeleton = Instantiate(gameObject);
newSkeleton.AddComponent<SkeletonAnimation>();
newSkeleton.GetComponent<SkeletonAnimation>().skeletonDataAsset = skeletonDataAsset;
newSkeleton.GetComponent<SkeletonAnimation>().Initialize(true);
createdSkeletonObject = newSkeleton.gameObject;
}
void UnloadSkeleton() {
var meshRenderer = createdSkeletonObject.GetComponent<MeshRenderer>();
Resources.UnloadAsset(meshRenderer.material.mainTexture);
Destroy(createdSkeletonObject);
}
The problem is. I can load the animation and I can unload it, but only once. When I want to load the same Skeleton Data Asset once again I do not see it on the screen. In hierarchy, everything looks fine.
Do you know how can I solve this problem? Maybe another way of unloading textures? I wanted to unload whole Skeleton Data Asset, but it does not disappear from the memory.