using UnityEngine; namespace WS { [ObjectSystem] public class LoadEffectComponentAwakeSystem : AwakeSystem { public override void Awake(LoadEffectComponent self) { var go = Resources.Load("Material/LoadingEffect/LoadingEffect"); self.loadEffect = GameObject.Instantiate(go, Game.Init); self.loadEffectMat = Resources.Load("Material/LoadingEffect/FullScreen_FullScreenCustomPass"); } } [ObjectSystem] public class LoadEffectComponentUpdateSystem : UpdateSystem { public override void Update(LoadEffectComponent self) { if (self.isPlay) { if (self.timer <= self.durtaion) { self.timer += Time.deltaTime; if (self.isShow) { self.loadEffectMat.SetFloat("_EffectTimer", 1); } else { self.loadEffectMat.SetFloat("_EffectTimer", Mathf.Lerp(1, 0, self.timer / self.durtaion)); } } else { self.isPlay=false; self.timer=0; } } } } public class LoadEffectComponent : WSComponent { public GameObject loadEffect; public Material loadEffectMat; public bool isPlay; public bool isShow; public float timer=0; public float durtaion=2f; public void PlayLoadEffect(bool show) { isPlay = true; isShow = show; } } }