For our game, we have characters with lots of clothing and body options. This works great at runtime. However, we want to be able to configure the settings in the editor. Our configuration tools all work great, and once the game is running the skins appear as they are supposed to. However, in editor mode, we are unable to get the skins to display at all. This is a feature that used to work about 6 months ago (or so), and no longer appears to function.
This is the method we use to rebuild our skins:
public void RebuildCustomSkin()
{
if (skeletonAnimation == null || skeleton == null)
{
Debug.Log("
---
SKIN BUILD ABORT
---
" + gameObject.name);
return;
}
customSkin.Clear();
foreach (PlayerAnimationSkin thisSkin in ActiveSkins)
{
Skin appSkin = skeleton.Data.FindSkin(thisSkin.SkinName);
if (appSkin == null)
{
Debug.LogWarning("
---
No skin named " + thisSkin.SkinName + " found on skeleton of object " + gameObject.name);
return;
}
else
{
customSkin.Append(appSkin);
}
}
skeleton.SetSkin(customSkin);
skeleton.SetToSetupPose();
animationStateComponent.AnimationState.Apply(skeleton);
}
The PlayerAnimationSkin object is our own internal object that just stores some internal data about the skins (such as if it is displayed by default or not) - but the key element is that it has the 'SkinName' stored as a string. We have gone as far as making sure this method is called in the Update look of the editor by adding [ExecuteInEditMode] [ExecuteAlways] to the top of the object class, running UnityEditor.EditorApplication.QueuePlayerLoopUpdate(); in OnEnable, and also running UnityEditor.EditorApplication.QueuePlayerLoopUpdate(); in every Update loop to ensure it keeps getting updated.
In addition, what appears to be happening is that the SkeletonAnimation component is always erasing the settings in editor mode, and replacing them with whatever the value of "Initial Skin" is - based on watching the skin flash for a fraction of a second to the values we set, then return to whatever is set in Initial Skin on SkeletonAnimation.
Any pointers would be very helpful as this is a frustration for us.
Thank you!!