123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using ET;
- using Animancer;
- using UnityEngine;
- using System;
- namespace Mono
- {
- public class AnimationData : MonoBehaviour
- {
- public AnimancerComponent Animancer;
- public enum AnimationType
- {
- Idle,
- Run,
- Dead,
- Skill0,
- Skill1,
- Skill2,
- Skill3
- }
- [System.Serializable]
- public struct AniInfo
- {
- public AnimationType Type;
- public ClipTransition Clip;
- }
- public AniInfo[] AnimationClips = new AniInfo[1];
- public ClipTransition GetClip(AnimationType type)
- {
- foreach (var clip in AnimationClips)
- {
- if (clip.Type == type)
- {
- return clip.Clip;
- }
- }
- return null;
- }
- public void PlayAnimation(AnimationType type, Action endcb = null)
- {
- var clip = GetClip(type);
- if (clip != null)
- {
- Log.Debug($"Play ani: {type}");
- var state = Animancer.Play(clip);
- state.Time = 0;
- if(endcb != null)
- {
- state.Events.OnEnd = endcb;
- }
- }
- else
- {
- Log.Error($"Not exist clip({type}) @{gameObject.name}");
- }
- }
- }
- }
|