using System.Collections; using System.Collections.Generic; using UnityEngine; using LzFramework; using DG.Tweening; namespace DisComputer { /* * @func 灯光动画控制 * @author lz * @date 2020/07/14 * */ public class GamePCLighter : Singleton { //主灯光 public Light _main_light; public Color[] colors; public List spareLightConfigs; private Light[] lights; private Tween lightTw; // Start is called before the first frame update void Start() { lights = transform.GetComponentsInChildren(); HideLight(); } /// /// 设置灯光颜色 /// /// public void SetLightColor(string name) { for(int i = 0;i < spareLightConfigs.Count; i++) { if(spareLightConfigs[i].name == name) { Debug.LogFormat("Name{0}", name); for(int k = 0; k < lights.Length; k++) { lights[k].color = spareLightConfigs[i].color; } break; } } } /// /// 显示灯光 /// public void ShowLight() { this.gameObject.SetActive(true); _main_light.intensity = 8; lightTw = _main_light.DOIntensity(20, 1.0f).SetEase(Ease.Linear).SetLoops(-1,LoopType.Yoyo); } /// /// 隐藏灯光 /// public void HideLight() { lightTw.Kill(); this.gameObject.SetActive(false); } } [System.Serializable] public class SpareLightConfig { public string name; public Color color; } }