Elin Decompiled Documentation EA 23.264 Nightly
Loading...
Searching...
No Matches
RainbowTextColor Class Reference
Inheritance diagram for RainbowTextColor:

Public Member Functions

void Play ()
 
void Stop ()
 

Public Attributes

float duration = 3f
 
float cyclesPerSecond = 1f
 
float saturation = 1f
 
float value = 1f
 
float alphaMultiplier = 1f
 
bool playOnEnable = true
 
bool restoreOriginalColor = true
 

Private Member Functions

void Awake ()
 
void OnEnable ()
 
void OnDisable ()
 
IEnumerator Run ()
 

Private Attributes

Text _text
 
Coroutine _routine
 
Color _originalColor
 

Detailed Description

Definition at line 7 of file RainbowTextColor.cs.

Member Function Documentation

◆ Awake()

void RainbowTextColor.Awake ( )
inlineprivate

Definition at line 45 of file RainbowTextColor.cs.

46 {
47 _text = GetComponent<Text>();
48 _originalColor = _text.color;
49 }

References _originalColor, and _text.

◆ OnDisable()

void RainbowTextColor.OnDisable ( )
inlineprivate

Definition at line 59 of file RainbowTextColor.cs.

60 {
61 Stop();
62 if (restoreOriginalColor && _text != null)
63 {
64 _text.color = _originalColor;
65 }
66 }

References _originalColor, _text, restoreOriginalColor, and Stop().

◆ OnEnable()

void RainbowTextColor.OnEnable ( )
inlineprivate

Definition at line 51 of file RainbowTextColor.cs.

52 {
53 if (playOnEnable)
54 {
55 Play();
56 }
57 }

References Play(), and playOnEnable.

◆ Play()

void RainbowTextColor.Play ( )
inline

Definition at line 68 of file RainbowTextColor.cs.

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 }
IEnumerator Run()

References _originalColor, _routine, _text, and Run().

Referenced by OnEnable().

◆ Run()

IEnumerator RainbowTextColor.Run ( )
inlineprivate

Definition at line 98 of file RainbowTextColor.cs.

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 }
115 {
116 _text.color = _originalColor;
117 }
118 _routine = null;
119 }

References _originalColor, _routine, alphaMultiplier, Color, cyclesPerSecond, duration, restoreOriginalColor, saturation, and value.

Referenced by Play().

◆ Stop()

void RainbowTextColor.Stop ( )
inline

Definition at line 85 of file RainbowTextColor.cs.

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 }

References _originalColor, _routine, _text, and restoreOriginalColor.

Referenced by OnDisable().

Member Data Documentation

◆ _originalColor

Color RainbowTextColor._originalColor
private

Definition at line 43 of file RainbowTextColor.cs.

Referenced by Awake(), OnDisable(), Play(), Run(), and Stop().

◆ _routine

Coroutine RainbowTextColor._routine
private

Definition at line 41 of file RainbowTextColor.cs.

Referenced by Play(), Run(), and Stop().

◆ _text

Text RainbowTextColor._text
private

Definition at line 39 of file RainbowTextColor.cs.

Referenced by Awake(), OnDisable(), Play(), and Stop().

◆ alphaMultiplier

float RainbowTextColor.alphaMultiplier = 1f

Definition at line 30 of file RainbowTextColor.cs.

Referenced by Run().

◆ cyclesPerSecond

float RainbowTextColor.cyclesPerSecond = 1f

Definition at line 17 of file RainbowTextColor.cs.

Referenced by Run().

◆ duration

float RainbowTextColor.duration = 3f

Definition at line 12 of file RainbowTextColor.cs.

Referenced by Run().

◆ playOnEnable

bool RainbowTextColor.playOnEnable = true

Definition at line 34 of file RainbowTextColor.cs.

Referenced by OnEnable().

◆ restoreOriginalColor

bool RainbowTextColor.restoreOriginalColor = true

Definition at line 37 of file RainbowTextColor.cs.

Referenced by OnDisable(), Run(), and Stop().

◆ saturation

float RainbowTextColor.saturation = 1f

Definition at line 22 of file RainbowTextColor.cs.

Referenced by Run().

◆ value

float RainbowTextColor.value = 1f

Definition at line 26 of file RainbowTextColor.cs.

Referenced by Run().


The documentation for this class was generated from the following file: