forked from whztt07/UnityGameplayAbilitySystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimationEventSystem.cs
More file actions
62 lines (52 loc) · 1.91 KB
/
Copy pathAnimationEventSystem.cs
File metadata and controls
62 lines (52 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System.Collections;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Events;
namespace GameplayAbilitySystem {
/// <summary>
/// Animation event
/// </summary>
/// <typeparam name="AnimationEvent"></typeparam>
[AddComponentMenu("Gameplay Ability System/Animation Event System")]
[System.Serializable]
public class CustomAnimationUnityEvent : UnityEvent<AnimationEvent> {
}
/// <summary>
/// An Animation Event System for managing animation on a component and returning animation events
/// </summary>
public class AnimationEventSystem : MonoBehaviour {
public AnimationEvent PreviousAnimationEvent;
/// <summary>
/// Delegate to execute when custom animation events are triggered on the character
/// </summary>
public CustomAnimationUnityEvent CustomAnimationEvent = new CustomAnimationUnityEvent();
/// <summary>
/// Delegate to execute when the player animation is complete
/// </summary>
public UnityEvent AnimationComplete;
/// <summary>
/// Delegate to execute when the player animation starts
/// </summary>
public UnityEvent AnimationStarted;
/// <summary>
/// Run when an animation event occurs
/// </summary>
/// <param name="eventName">Name of the animation event that occured</param>
public void OnAnimationEvent(AnimationEvent evt) {
CustomAnimationEvent?.Invoke(evt);
this.PreviousAnimationEvent = evt;
}
/// <summary>
/// Run when an animation completes
/// </summary>
public void OnAnimationComplete() {
AnimationComplete?.Invoke();
}
/// <summary>
/// Run when an animation starts
/// </summary>
public void OnAnimationStarted() {
AnimationStarted?.Invoke();
}
}
}