using UnityEngine; using UniRx; public class Lumos : MonoBehaviour { public Color NormalColor = Color.white; public Color TargetColor = Color.red; private float time; private bool LumosReady; public float Interval = 0.3f; private void Start() { Observable.EveryLateUpdate() .Where(_=>this.enabled) .Subscribe(_ => { time += Time.deltaTime; if (time > Interval) { time = 0.0f; LumosReady = !LumosReady; } if (LumosReady) GetComponent().material.SetColor("_Color", NormalColor); else GetComponent().material.SetColor("_Color", TargetColor); }).AddTo(gameObject); } private void OnDisable() { GetComponent().material.SetColor("_Color", NormalColor); } }