Nextrek
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
//----------------------------------------------
// NGUI: Next-Gen UI kit
// Copyright © 2011-2013 Tasharen Entertainment
//----------------------------------------------
using UnityEngine;
/// <summary>
/// Tween the object's alpha.
/// </summary>
[AddComponentMenu("NGUI/Tween/Tween Alpha")]
public class TweenAlpha : UITweener
{
#if UNITY_3_5
public float from = 1f;
public float to = 1f;
#else
[Range(0f, 1f)] public float from = 1f;
[Range(0f, 1f)] public float to = 1f;
#endif
Transform mTrans;
UIWidget mWidget;
UIPanel mPanel;
/// <summary>
/// Current alpha.
/// </summary>
public float alpha
{
get
{
if (mWidget != null) return mWidget.alpha;
if (mPanel != null) return mPanel.alpha;
return 0f;
}
set
{
if (mWidget != null) mWidget.alpha = value;
else if (mPanel != null) mPanel.alpha = value;
}
}
/// <summary>
/// Find all needed components.
/// </summary>
void Awake ()
{
mPanel = GetComponent<UIPanel>();
if (mPanel == null) mWidget = GetComponentInChildren<UIWidget>();
}
/// <summary>
/// Interpolate and update the alpha.
/// </summary>
protected override void OnUpdate (float factor, bool isFinished) { alpha = Mathf.Lerp(from, to, factor); }
/// <summary>
/// Start the tweening operation.
/// </summary>
static public TweenAlpha Begin (GameObject go, float duration, float alpha)
{
TweenAlpha comp = UITweener.Begin<TweenAlpha>(go, duration);
comp.from = comp.alpha;
comp.to = alpha;
if (duration <= 0f)
{
comp.Sample(1f, true);
comp.enabled = false;
}
return comp;
}
}
|
Revision |
Author |
Commited |
Message |
83
|
FMMortaroli
|
Tue 13 May, 2014 11:32:51 +0000 |
|