public void Update() { if (_transitioning) { _outCanvas.alpha = _tweenAlphaOut.Value; _inCanvas.alpha = _tweenAlphaIn.Value; if (!_tweenAlphaIn.Tweening && !_tweenAlphaOut.Tweening) { _out.SetVisibility(false); _transitioning = false; _onComplete(_in); _onComplete = null; } } }
public void Transition(MenuBase from, MenuBase to, Action <MenuBase> onComplete) { _out = from; _in = to; _in.SetVisibility(true); _outCanvas = from.gameObject.GetOrAddComponent <CanvasGroup>(); _inCanvas = to.gameObject.GetOrAddComponent <CanvasGroup>(); _onComplete = onComplete; _tweenAlphaIn.Duration = TransitionTime; _tweenAlphaOut.Duration = TransitionTime; _tweenAlphaIn.Play(); _tweenAlphaOut.Play(); _transitioning = true; }