|
@@ -33,6 +33,32 @@ namespace Mono
|
|
|
}
|
|
|
|
|
|
public AniInfo[] AnimationClips = new AniInfo[1];
|
|
|
+ private Action aniEndcb;
|
|
|
+ private AnimancerState notifyState;
|
|
|
+
|
|
|
+ private void Awake ()
|
|
|
+ {
|
|
|
+ aniEndcb = null;
|
|
|
+ foreach (var clip in AnimationClips)
|
|
|
+ {
|
|
|
+ if (clip.Type >= AnimationType.Skill0 && clip.Type < AnimationType.SkillMax)
|
|
|
+ {
|
|
|
+ clip.Clip.Events.OnEnd = SkillEndCB;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void SkillEndCB()
|
|
|
+ {
|
|
|
+ if(notifyState != null /*&& notifyState.IsPlaying*/)
|
|
|
+ {
|
|
|
+ notifyState.Events = null;
|
|
|
+ notifyState = null;
|
|
|
+ }
|
|
|
+ Action tocall = aniEndcb;
|
|
|
+ aniEndcb = null;
|
|
|
+ tocall?.Invoke();
|
|
|
+ }
|
|
|
|
|
|
public ClipTransition GetClip(AnimationType type)
|
|
|
{
|
|
@@ -45,25 +71,20 @@ namespace Mono
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
public void PlayAnimation(AnimationType type, Action endcb = null)
|
|
|
{
|
|
|
+ Log.Debug($"{this.gameObject.name} toplay ani:{type}");
|
|
|
+ aniEndcb = endcb;
|
|
|
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;
|
|
|
- }
|
|
|
+ notifyState = Animancer.Play(clip, 0.1f, FadeMode.FromStart);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Log.Error($"Not exist clip({type}) @{gameObject.name}");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|