- Home /
Check if a Spine skin exists
I have 2 characters (a gameobject with the spine stuff). 1 with generic enemies skins, and other with bosses skins. I have a string with the name of the skin, and I want to check on which of the 2 characters that skin exists . I don't find a method for this. I have skeletonAnimation.skeleton.Skin to get the actual skin, but not the list of all available skins.
Answer by k234234w · Jun 04, 2019 at 11:56 PM
Here are some extension methods.
public static class SpineExtensions
{
public static bool CheckIfAnimationExists(this Spine.AnimationState animationState, string animationToUse)
{
if(animationState == null)
{
return false;
}
if(animationState.Data.SkeletonData.FindAnimation(animationToUse) != null)
{
return true;
}
return false;
}
public static bool CheckIfAnimationExists(this Spine.AnimationState animationState, Spine.Animation animationToUse)
{
if(animationState == null)
{
return false;
}
if(animationState.Data.SkeletonData.FindAnimation(animationToUse.Name) != null)
{
return true;
}
return false;
}
public static bool CheckIfSkinExists(this Spine.AnimationState animationState, string skinToUse)
{
if (animationState == null)
{
return false;
}
if (animationState.Data.SkeletonData.FindSkin(skinToUse) != null)
{
return true;
}
return false;
}
public static bool CheckIfSkinExists(this Spine.AnimationState animationState, Spine.Skin skin)
{
if (animationState == null)
{
return false;
}
if (animationState.Data.SkeletonData.FindSkin(skin.Name) != null)
{
return true;
}
return false;
}
}
You can get the Spine.AnimationState from the SkeletonAnimation component, then you would just call one of the corresponding CheckIfSkinExists extension methods i posted, or write your own. But the above shows you how you can check to see if the SkeletonData has your desired skin.
Your answer
Follow this Question
Related Questions
Share rig vs share animation 0 Answers
My imported skinned mesh's vertices act funny 1 Answer
Guiskin: how to change font color? 0 Answers
Cannot change editor skin with Unity Pro 0 Answers
GUI Null Reference Exception? 2 Answers