Add rainbow image scripts

This commit is contained in:
2025-09-04 15:47:40 -07:00
parent 1910170ae7
commit 3332c12711
4 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
using UnityEngine;
public class RainbowSpriteRender : MonoBehaviour
{
public float frequency = 1f;
private SpriteRenderer targetImage;
void Awake()
{
targetImage = gameObject.GetComponent<SpriteRenderer>();
}
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);
}
}