Elin Decompiled Documentation
EA 23.264 Nightly
Loading...
Searching...
No Matches
RainbowTextColor.cs
Go to the documentation of this file.
1
using
System.Collections;
2
using
UnityEngine;
3
using
UnityEngine.UI;
4
5
[DisallowMultipleComponent]
6
[RequireComponent(typeof(Text))]
7
public
sealed
class
RainbowTextColor
: MonoBehaviour
8
{
9
[
Header
(
"Duration"
)]
10
[
Tooltip
(
"虹色アニメーションを行う秒数"
)]
11
[Min(0f)]
12
public
float
duration
= 3f;
13
14
[
Header
(
"Speed"
)]
15
[
Tooltip
(
"1秒あたり何周Hueを回すか(1=1周/秒)"
)]
16
[Min(0f)]
17
public
float
cyclesPerSecond
= 1f;
18
19
[
Header
(
"Look"
)]
20
[
Tooltip
(
"彩度"
)]
21
[
Range
(0f, 1f)]
22
public
float
saturation
= 1f;
23
24
[
Tooltip
(
"明度"
)]
25
[
Range
(0f, 1f)]
26
public
float
value
= 1f;
27
28
[
Tooltip
(
"元のアルファに対して掛ける係数(1=そのまま)"
)]
29
[
Range
(0f, 1f)]
30
public
float
alphaMultiplier
= 1f;
31
32
[
Header
(
"Playback"
)]
33
[
Tooltip
(
"開始時に自動再生"
)]
34
public
bool
playOnEnable
=
true
;
35
36
[
Tooltip
(
"終了時に元の色へ戻す"
)]
37
public
bool
restoreOriginalColor
=
true
;
38
39
private
Text
_text
;
40
41
private
Coroutine
_routine
;
42
43
private
Color
_originalColor
;
44
45
private
void
Awake
()
46
{
47
_text
= GetComponent<Text>();
48
_originalColor
=
_text
.color;
49
}
50
51
private
void
OnEnable
()
52
{
53
if
(
playOnEnable
)
54
{
55
Play
();
56
}
57
}
58
59
private
void
OnDisable
()
60
{
61
Stop
();
62
if
(
restoreOriginalColor
&&
_text
!=
null
)
63
{
64
_text.color =
_originalColor
;
65
}
66
}
67
68
public
void
Play
()
69
{
70
if
(
_text
==
null
)
71
{
72
_text
= GetComponent<Text>();
73
}
74
if
(!(
_text
==
null
))
75
{
76
_originalColor
=
_text
.color;
77
if
(
_routine
!=
null
)
78
{
79
StopCoroutine(
_routine
);
80
}
81
_routine
= StartCoroutine(
Run
());
82
}
83
}
84
85
public
void
Stop
()
86
{
87
if
(
_routine
!=
null
)
88
{
89
StopCoroutine(
_routine
);
90
_routine
=
null
;
91
}
92
if
(
restoreOriginalColor
&&
_text
!=
null
)
93
{
94
_text.color =
_originalColor
;
95
}
96
}
97
98
private
IEnumerator
Run
()
99
{
100
if
(
duration
<= 0f)
101
{
102
_routine
=
null
;
103
yield
break
;
104
}
105
float
elapsed = 0f;
106
while
(elapsed <
duration
)
107
{
108
elapsed += Time.unscaledDeltaTime;
109
Color
color =
Color
.HSVToRGB(Mathf.Repeat(elapsed *
cyclesPerSecond
, 1f),
saturation
,
value
);
110
color.a = _originalColor.a *
alphaMultiplier
;
111
_text.color = color;
112
yield
return
null
;
113
}
114
if
(
restoreOriginalColor
)
115
{
116
_text.color =
_originalColor
;
117
}
118
_routine
=
null
;
119
}
120
}
AttackSource.Range
@ Range
FOWType.Color
@ Color
FontColor.Header
@ Header
SkinType.Tooltip
@ Tooltip
RainbowTextColor
Definition:
RainbowTextColor.cs:8
RainbowTextColor.Awake
void Awake()
Definition:
RainbowTextColor.cs:45
RainbowTextColor.value
float value
Definition:
RainbowTextColor.cs:26
RainbowTextColor._text
Text _text
Definition:
RainbowTextColor.cs:39
RainbowTextColor.OnEnable
void OnEnable()
Definition:
RainbowTextColor.cs:51
RainbowTextColor.duration
float duration
Definition:
RainbowTextColor.cs:12
RainbowTextColor.alphaMultiplier
float alphaMultiplier
Definition:
RainbowTextColor.cs:30
RainbowTextColor.OnDisable
void OnDisable()
Definition:
RainbowTextColor.cs:59
RainbowTextColor.playOnEnable
bool playOnEnable
Definition:
RainbowTextColor.cs:34
RainbowTextColor.Stop
void Stop()
Definition:
RainbowTextColor.cs:85
RainbowTextColor.Run
IEnumerator Run()
Definition:
RainbowTextColor.cs:98
RainbowTextColor.cyclesPerSecond
float cyclesPerSecond
Definition:
RainbowTextColor.cs:17
RainbowTextColor.saturation
float saturation
Definition:
RainbowTextColor.cs:22
RainbowTextColor.restoreOriginalColor
bool restoreOriginalColor
Definition:
RainbowTextColor.cs:37
RainbowTextColor.Play
void Play()
Definition:
RainbowTextColor.cs:68
RainbowTextColor._originalColor
Color _originalColor
Definition:
RainbowTextColor.cs:43
RainbowTextColor._routine
Coroutine _routine
Definition:
RainbowTextColor.cs:41
Elin
Plugins.UI
RainbowTextColor.cs
Generated by
1.9.6