BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / GAME / Scripts / BlinkyLight.cs

BlinkyLight.cs

f93b9f9e History
BlinkyLight.cs 981 B Download Raw
1using System.Collections;
2using System.Collections.Generic;
3using UnityEngine;
4
5public class BlinkyLight : MonoBehaviour
6{
7 private Tween blinkTween = new Tween(Easing.EaseInOutCubic);
8 [SerializeField] private Renderer lightModelRenderer;
9 [SerializeField] private Light light;
10 private bool on = false;
11
12 // Start is called before the first frame update
13 void Start()
14 {
15 blinkTween.onChange = t =>
16 {
17 light.range = t * 10;
18 lightModelRenderer.material.color = Color.Lerp(Color.black, Color.red, t);
19 light.intensity = t * 10;
20 };
21 }
22
23 // Update is called once per frame
24 void Update()
25 {
26 if(!blinkTween.active)
27 {
28 if(on)
29 {
30 on = false;
31 blinkTween.Start(1, 0, 0.8f);
32 }
33 else
34 {
35 on = true;
36 blinkTween.Start(0, 1, 0.8f);
37 }
38 }
39 }
40}