using UnityEngine; using UnityEngine.UI; [DisallowMultipleComponent] public class DeviceLumos : MonoBehaviour { public Color NormalColor = Color.white; public Color TargetColor = Color.red; private float time; private bool LumosReady; private float Interval = 0.5f; private void Awake() { if (GetComponent()) { NormalColor = GetComponent().material.color; TargetColor = Color.red; } else if (GetComponent()) { NormalColor = GetComponent().color; TargetColor = Color.blue; } } private void LateUpdate() { time += Time.deltaTime; if (time > Interval) { time = 0.0f; LumosReady = !LumosReady; } if (GetComponent()) { if (LumosReady) { GetComponent().material.SetColor("_Color", NormalColor); } else { GetComponent().material.SetColor("_Color", TargetColor); } } else if (GetComponent()) { if (LumosReady) { GetComponent().color = NormalColor; } else { GetComponent().color = TargetColor; } } } private void OnDestroy() { if (GetComponent()) { GetComponent().material.SetColor("_Color", NormalColor); } else if (GetComponent()) { GetComponent().color = NormalColor; } } }