blob: c902ae262dc8e6cee5fa53230c2f125bbf0fb89c (
plain)
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
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 某个动画是否播放到了某个时间(归一化了的)范围内
/// </summary>
public sealed class ConditionMotionRange : ConditionBase
{
Vector2 m_TimeRange = new Vector2();
Animator m_Animator;
public ConditionMotionRange(Animator animator, float start, float end)
{
m_Animator = animator;
m_TimeRange.Set(start, end);
}
public override bool Evaluate()
{
AnimatorStateInfo info = m_Animator.GetCurrentAnimatorStateInfo(0);
float time = info.normalizedTime;
bool result = time >= m_TimeRange.x && time <= m_TimeRange.y;
return result;
}
}
|