I've was using the Spine2D integration here: https://adventure-creator.fandom.com/wiki/Spine_Integration, but the skin wouldn't be saved, so if the player had a skin in a scene I was loading from, it would carry over to the scene I was loading to.
Here is a script I wrote to remember the skin, attach to the GameObject with the SkeletonAnimation:
using UnityEngine;
using Spine.Unity;
using AC;
public class RememberSkin : Remember
{
public override string SaveData()
{
string skinName = GetComponent<SkeletonAnimation>().Skeleton.Skin.Name;
CustomSkinData skinData = new CustomSkinData();
skinData.characterName = gameObject.name;
skinData.skinName = skinName;
return Serializer.SaveScriptData<CustomSkinData>(skinData);
}
public override void LoadData(string stringData)
{
CustomSkinData data = Serializer.LoadScriptData<CustomSkinData>(stringData);
SkeletonAnimation skeletonAnimation = GetComponent<SkeletonAnimation>();
if (data != null && skeletonAnimation != null && data.characterName == gameObject.name)
{
skeletonAnimation.Skeleton.SetSkin(data.skinName); // Apply the saved skin
skeletonAnimation.Skeleton.SetSlotsToSetupPose(); // Refresh the skin
}
}
}
[System.Serializable]
public class CustomSkinData : RememberData
{
public string characterName; // Character identifier
public string skinName; // Spine2D skin name
public CustomSkinData() {}
}
It looks like you're new here. If you want to get involved, click one of these buttons!