/// <summary> /// Run a color (or alpha) tween animation /// </summary> /// <param name="endValue">End value when start is 0 and end is 1</param> /// <param name="duration"></param> /// <param name="ease">DG.Tweening.Ease</param> /// <param name="delay"></param> public void AnimateColor(float endValue, float duration, Ease ease = Ease.Linear, float delay = 0) { if (useColor == ColorType.None) { return; } ForceActive(); if (useColor != ColorType.None) { colorTween?.Kill(); } switch (useColor) { case ColorType.Alpha: colorTween = maskableGraphic.DOFade(GetAlphaLeap(endValue), duration).SetEase(ease).SetDelay(delay); break; case ColorType.Color: colorTween = maskableGraphic.DOColor(GetColorLeap(endValue), duration).SetEase(ease).SetDelay(delay); break; } if (useColor != ColorType.None && endValue == 0) { colorTween.OnComplete(() => ForceInactive()); } }
private void Start() { Sequence seq = DOTween.Sequence(); seq.Append(_fadeElem.DOFade(1f, _sequenceDuration)) .Join(_fadeElem.transform.DOScale(_endScale, seq.Duration())) //.Append(_fadeElem.DOFade(0f, _sequenceDuration / 4f)) .OnComplete(() => { _mainMenu.SetActive(true); }); }
public override Tween Play(float duration) { if (mask != null) { mask.enabled = true; } Observable.Timer(TimeSpan.FromSeconds(duration)) .Subscribe(_ => { if (mask != null) { mask.enabled = false; } }); return(target.DOFade(to, duration).SetEase(easeType)); }
public static Tweener DoFade(MaskableGraphic tras, float endValue, float duration, Ease easeType, Action onComplete, float stepTime = 1f, Action onStepComplete = null) { Tweener tweener = tras.DOFade(endValue, duration).SetEase(easeType); if (onStepComplete != null) { DoStep(tweener, stepTime, onStepComplete); } tweener.onComplete = () => { if (onComplete != null) { onComplete(); } }; CheckPause(); return(tweener); }
public void FadeOff() { graphic.DOFade(0f, timeToFade) .SetDelay(delay) .SetEase(easeType); }