在UGUI中用代码创建Spine 动画

在UGUI中用代码创建Spine 动画

// An highlighted block
using UnityEngine;
using Spine.Unity;

public class SpineTest : MonoBehaviour {
    void Start () {
        CreateCharacter();
    }	
    private void CreateCharacter()
    {
        SkeletonDataAsset playerData = ScriptableObject.CreateInstance<SkeletonDataAsset>();
        playerData= Resources.Load<SkeletonDataAsset>("ren_1/ren1_SkeletonData");
        var spineAnimation = playerData.GetSkeletonData(false).FindAnimation("1_1");
        var sa = SkeletonGraphic.NewSkeletonGraphicGameObject(playerData,transform);
        if (spineAnimation != null)
        {
            sa.Initialize(false);
            sa.AnimationState.SetAnimation(0, spineAnimation, true);
        }
    }
}

你可能感兴趣的:(spine)