12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- 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,
- Skill4,
- Skill5,
- Skill6,
- SkillMax
- }
- [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)
- {
- var state = Animancer.Play(clip);
- state.Time = 0;
- if(endcb != null)
- {
- state.Events.OnEnd = endcb;
- }
- }
- else
- {
- Log.Error($"Not exist clip({type}) @{gameObject.name}");
- }
- }
- }
- }
|