Screw it, I added light
This commit is contained in:
29
Assets/LightCycle.cs
Normal file
29
Assets/LightCycle.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
public class LightCycle : MonoBehaviour
|
||||
{
|
||||
public List<Color> colors;
|
||||
|
||||
public int targetColorIndex = 0;
|
||||
|
||||
public float speed = 1.0f;
|
||||
|
||||
private Light2D light2D;
|
||||
|
||||
void Start()
|
||||
{
|
||||
light2D = GetComponent<Light2D>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (light2D.color == colors[targetColorIndex])
|
||||
{
|
||||
targetColorIndex = (targetColorIndex + 1) % colors.Count;
|
||||
}
|
||||
|
||||
light2D.color = Color.Lerp(light2D.color, colors[targetColorIndex], Time.deltaTime * speed);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user