I have a GameObject that has an AnimationController component, with an AnimationName property. The Spine object is a child object of this GameObject.
Inside OnValidate on the parent object, I set the AnimationName property of the SkeletonAnimation component, expecting it will change the look of the animation inside Unity Editor. However, this doesn't happen. If I manually change the AnimationName property of the Spine game object, it re-draws the animation correctly.
I took a look inside SkeletonAnimationInspector and I noticed there's a lot of things going on inside TrySetAnimation. Is there an easy way I can trigger the call to this method, just like it gets called from the inspector?
Basically, what I want is to change AnimationName programmatically from the editor, and have it do exactly the same thing as changing AnimationName from SkeletonGraphic's inspector.
This is how I'm changing the name right now:
private void OnValidate()
{
if (animation == null)
{
animation = GetComponentInChildren<SkeletonAnimation>();
}
if (!animation.valid)
{
animation.Initialize(false);
}
animation.AnimationName = AnimationName;
}