diff options
| author | dereelatwit <54997325+dereelatwit@users.noreply.github.com> | 2023-08-03 14:05:08 -0400 |
|---|---|---|
| committer | dereelatwit <54997325+dereelatwit@users.noreply.github.com> | 2023-08-03 14:05:08 -0400 |
| commit | b8aa2e0935f309b112648f0352f35f5f33da946b (patch) | |
| tree | 9121ae1a65e483dddba8367cbbdd4991abfb3e26 /Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/ShaderPropAnimator.cs | |
| parent | 374125ba34e0366afb062578906877cfdf229bb9 (diff) | |
started implementing UI
Diffstat (limited to 'Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/ShaderPropAnimator.cs')
| -rw-r--r-- | Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/ShaderPropAnimator.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/ShaderPropAnimator.cs b/Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/ShaderPropAnimator.cs new file mode 100644 index 0000000..d8e56a4 --- /dev/null +++ b/Pathfinding Visualizer/Assets/TextMesh Pro/Examples & Extras/Scripts/ShaderPropAnimator.cs @@ -0,0 +1,51 @@ +using UnityEngine; +using System.Collections; + + +namespace TMPro.Examples +{ + + public class ShaderPropAnimator : MonoBehaviour + { + + private Renderer m_Renderer; + private Material m_Material; + + public AnimationCurve GlowCurve; + + public float m_frame; + + void Awake() + { + // Cache a reference to object's renderer + m_Renderer = GetComponent<Renderer>(); + + // Cache a reference to object's material and create an instance by doing so. + m_Material = m_Renderer.material; + } + + void Start() + { + StartCoroutine(AnimateProperties()); + } + + IEnumerator AnimateProperties() + { + //float lightAngle; + float glowPower; + m_frame = Random.Range(0f, 1f); + + while (true) + { + //lightAngle = (m_Material.GetFloat(ShaderPropertyIDs.ID_LightAngle) + Time.deltaTime) % 6.2831853f; + //m_Material.SetFloat(ShaderPropertyIDs.ID_LightAngle, lightAngle); + + glowPower = GlowCurve.Evaluate(m_frame); + m_Material.SetFloat(ShaderUtilities.ID_GlowPower, glowPower); + + m_frame += Time.deltaTime * Random.Range(0.2f, 0.3f); + yield return new WaitForEndOfFrame(); + } + } + } +} |
