-
Notifications
You must be signed in to change notification settings - Fork 12
/
AnimatorAwaitEx.cs
34 lines (29 loc) · 1.07 KB
/
AnimatorAwaitEx.cs
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
using UnityEngine;
using zFrame.Event;
public static class AnimatorAwaitEx
{
public static AnimationAwaiter SetBoolAsync(this Animator animator,string clipName, string paramName, bool value)
{
var awaiter = new AnimationAwaiter();
var state = animator.SetTarget(clipName);
state.OnCompleted(awaiter.SetResult);
state.SetBool(paramName, value);
return awaiter;
}
public static AnimationAwaiter SetTriggerAsync(this Animator animator, string clipName, string paramName)
{
var awaiter = new AnimationAwaiter();
var state = animator.SetTarget(clipName);
state.OnCompleted(awaiter.SetResult);
state.SetTrigger(paramName);
return awaiter;
}
public static AnimationAwaiter SetFloatAsync(this Animator animator, string clipName, string paramName, float value)
{
var awaiter = new AnimationAwaiter();
var state = animator.SetTarget(clipName);
state.OnCompleted(awaiter.SetResult);
state.SetFloat(paramName, value);
return awaiter;
}
}