上海虹口龙之梦项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
973 B

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<Renderer>().material.SetColor("_Color", NormalColor);
else
GetComponent<Renderer>().material.SetColor("_Color", TargetColor);
}).AddTo(gameObject);
}
private void OnDisable()
{
GetComponent<Renderer>().material.SetColor("_Color", NormalColor);
}
}