Onepengr 发表于 2022-10-14 14:04

using System.Collections;
using UnityEngine;
using Spine.Unity;
namespace Game
{
    //
    public class SpineForAnimator : MonoBehaviour
    {
      
      
      public int index = 0;

      
      public bool loop = false;

      private SkeletonGraphic _ui;
      private SkeletonAnimation _scene;
      private int _playingIdx = -1;

      private void Awake()
      {
            _ui = GetComponent<SkeletonGraphic>();
            _scene = GetComponent<SkeletonAnimation>();
      }

      private void Update()
      {
            if (_playingIdx == index)
            {
                return;
            }
            if (_ui != null)
            {
                PlayUISpine();
            }else if (_scene != null)
            {
                PlaySceneSpine();
            }

      }

      private void PlayUISpine()
      {
            var animations = _ui.Skeleton.Data.Animations;
            Debug.Assert(index < animations.Count, "property index can not more than animation count!");
            var state = _ui.AnimationState;
            var willName = animations.Items.Name;
            //播放Spine动画
            state.ClearTrack(0);
            _ui.Skeleton.SetToSetupPose();
            state.SetAnimation(0, willName, loop);
            _playingIdx = index;
      }

      private void PlaySceneSpine()
      {
            var animations = _scene.skeleton.Data.Animations;
            Debug.Assert(index < animations.Count, "property index can not more than animation count!");
            var state = _scene.AnimationState;
            var willName = animations.Items.Name;
            //播放Spine动画
            state.ClearTrack(0);
            _scene.Skeleton.SetToSetupPose();
            state.SetAnimation(0, willName, loop);
            _playingIdx = index;
      }
    }
}

spine for unity animator 动画

Onepengr 发表于 2022-10-14 13:56

unity切换动画动画循环spine切换动作脚本(老何)












Onepengr 发表于 2022-10-11 22:22

tvp2013中文版

Onepengr 发表于 2022-9-27 13:28

云循环

Onepengr 发表于 2022-9-27 13:27

unity 天空盒跑云

Onepengr 发表于 2022-9-26 09:46

unity贴图particle中多个随机播放

Onepengr 发表于 2022-9-12 09:49

模型线转换成点

Onepengr 发表于 2022-9-12 09:41

uv动画修改器设置

Onepengr 发表于 2022-9-12 09:40

C:\Users\Administrator\Desktop\

Onepengr 发表于 2022-8-16 12:14

https://chengdu665/svn/witch
页: 1 2 3 4 5 [6] 7
查看完整版本: PSD导入AE 可分层控制方法