diff --git a/Assets/Scripts/RainbowImage.cs b/Assets/Scripts/RainbowImage.cs new file mode 100644 index 0000000..235c9f3 --- /dev/null +++ b/Assets/Scripts/RainbowImage.cs @@ -0,0 +1,22 @@ +using UnityEngine; +using UnityEngine.UI; + +public class RainbowImage : MonoBehaviour +{ + public float frequency = 1f; + private Image targetImage; + + void Awake() + { + targetImage = gameObject.GetComponent(); + } + + void Update() + { + float t = Time.time * frequency; + float r = Mathf.Sin(t) * 0.5f + 0.5f; + float g = Mathf.Sin(t + 2f) * 0.5f + 0.5f; + float b = Mathf.Sin(t + 4f) * 0.5f + 0.5f; + targetImage.color = new Color(r, g, b); + } +} diff --git a/Assets/Scripts/RainbowImage.cs.meta b/Assets/Scripts/RainbowImage.cs.meta new file mode 100644 index 0000000..d3ca689 --- /dev/null +++ b/Assets/Scripts/RainbowImage.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ac59fc58d5aba496f8a52d26fcfe16b0 \ No newline at end of file diff --git a/Assets/Scripts/RainbowSpriteRender.cs b/Assets/Scripts/RainbowSpriteRender.cs new file mode 100644 index 0000000..e125303 --- /dev/null +++ b/Assets/Scripts/RainbowSpriteRender.cs @@ -0,0 +1,21 @@ +using UnityEngine; + +public class RainbowSpriteRender : MonoBehaviour +{ + public float frequency = 1f; + private SpriteRenderer targetImage; + + void Awake() + { + targetImage = gameObject.GetComponent(); + } + + void Update() + { + float t = Time.time * frequency; + float r = Mathf.Sin(t) * 0.5f + 0.5f; + float g = Mathf.Sin(t + 2f) * 0.5f + 0.5f; + float b = Mathf.Sin(t + 4f) * 0.5f + 0.5f; + targetImage.color = new Color(r, g, b); + } +} diff --git a/Assets/Scripts/RainbowSpriteRender.cs.meta b/Assets/Scripts/RainbowSpriteRender.cs.meta new file mode 100644 index 0000000..6ffa84c --- /dev/null +++ b/Assets/Scripts/RainbowSpriteRender.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: a21a35a47faba4555ab8f7fa25ebe2a0 \ No newline at end of file