123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using UnityEngine;
- namespace WS
- {
- [ObjectSystem]
- public class LoadEffectComponentAwakeSystem : AwakeSystem<LoadEffectComponent>
- {
- public override void Awake(LoadEffectComponent self)
- {
- var go = Resources.Load<GameObject>("Material/LoadingEffect/LoadingEffect");
- self.loadEffect = GameObject.Instantiate(go, Game.Init);
- self.loadEffectMat = Resources.Load<Material>("Material/LoadingEffect/FullScreen_FullScreenCustomPass");
- }
- }
- [ObjectSystem]
- public class LoadEffectComponentUpdateSystem : UpdateSystem<LoadEffectComponent>
- {
- 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;
- }
- }
- }
|