blob: 2fd3742f4240415bc07472e8c1c8afd75a9ffd62 (
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// by chai
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace TweenAnimation
{
[Serializable]
public abstract class TweenModule
{
public bool enabled = true;
public float timeOffset = 0;
public float duration;
private float m_LastTime;
#if UNITY_EDITOR
public virtual string name { get { return ""; } }
public string description;
public virtual string tooltip { get { return "Tween Module " + name; } }
[NonSerialized]
public bool unfold;
#endif
private bool IsValidTime0(float time0)
{
return time0 >= 0 && time0 <= duration;
}
// 根据当前时间更新值, time的范围是tween animation的duration
public void OnUpdate(float time)
{
float time0 = time - timeOffset;
if (!IsValidTime0(time0) && !IsValidTime0(duration))
return;
m_LastTime = time0;
SetValue(Mathf.Clamp(time0, 0, duration));
}
// time是去掉了offset后的时间
protected abstract void SetValue(float time);
}
}
|