Oh thanks, that explains a lot.Anyway, about my second question, a new problem occurs when I am trying to use the skin system. First, I created a new skin, and removed the attachment which I want to hide .
newSkin.RemoveAttachment(item.Data.Index, item.Attachment.Name);
Then, I set the newskin to the current skin.
SkeletonAnimation.Skeleton.Skin = newSkin;
Since I hide the part of the new skin due to the need of my game mechanics, the character starts to acquire and display the data of the attachment from the Default Skin (which is something I do not want, the whole purpose of it is to make parts of my character disappeared). Therefore, after I created a new skin, I empty the DefaultSkindata .
SkeletonAnimation.Skeleton.Data.DefaultSkin.Clear();
However, when I use the same SkeletonDataAsset to create new character, the new character disappeared because there is no data in the DefaultSkin. So, what should I really do to achieve my desired outcome to hide the body part of my character?
SkeletonAnimation skelt = data.spineGB.GetComponent<SkeletonAnimation>();
Skin newSkin = skelt.Skeleton.GetClonedSkin("CurrentSkin", true);
Slot[] slots = skelt.skeleton.Slots.Items;
foreach (Slot item in slots)
{
if (item.ToString().Contains("leftHand") == true)
{
if (item.Attachment != null)
{
newSkin.RemoveAttachment(item.Data.Index, item.Attachment.Name);
}
}
}
skelt.Skeleton.Skin = newSkin;
skelt.Skeleton.Data.DefaultSkin = newSkin;
skelt.Skeleton.SetSlotsToSetupPose();
skelt.AnimationState.Apply(skelt.Skeleton);