public void update(float theFrac, OnFade onFade) { int increase = (int)(theFrac * mFadeSpeed); if (mFadeIn) { if (mColor.A + increase < 255) { mColor.A += (byte)increase; } else { mColor.A = 255; mFadeIn = false; onFade(); } } else if(mAutoFadeBack) { if (mColor.A - increase > 0) { mColor.A -= (byte)increase; } else { mColor.A = 0; } } }
void Awake() { creator = FindObjectOfType <TPFaderCreator>(); if (Fade == null) { Fade = () => creator.Fade(FadeToScene, FadeType); } }
private void DoFadeEvent(OnFade fade) { var target = (_canvasGroup.alpha >= 1) ? fadedAlpha : fullAlpha; Fade(_canvasGroup.alpha, target, fade.duration); }
private void OnDisable() { OnFade.UnregisterListener(DoFadeEvent); OnFadeIn.UnregisterListener(DoFadeInEvent); OnFadeOut.UnregisterListener(DoFadeOutEvent); }
private void OnEnable() { OnFade.RegisterListener(DoFadeEvent); OnFadeIn.RegisterListener(DoFadeInEvent); OnFadeOut.RegisterListener(DoFadeOutEvent); }
public void FadeEvent() { OnFade fade = new OnFade(defaultDuration); fade.FireEvent(); }
public void SetOnFade(OnFade _onFade) { Fade = _onFade; }