public virtual async Task SetIsVisibleAsync(bool isVisible, float?fadeTime = null) { if (fadeTweener.IsRunning) { fadeTweener.Stop(); } this.isVisible = isVisible; OnVisibilityChanged.SafeInvoke(isVisible); if (!CanvasGroup) { return; } CanvasGroup.interactable = isVisible; CanvasGroup.blocksRaycasts = isVisible; var fadeDuration = fadeTime ?? FadeTime; var targetOpacity = isVisible ? 1f : 0f; if (fadeDuration == 0f) { CanvasGroup.alpha = targetOpacity; return; } var tween = new FloatTween(CanvasGroup.alpha, targetOpacity, fadeDuration, alpha => CanvasGroup.alpha = alpha); await fadeTweener.RunAsync(tween); }
public virtual void OnPointerExit(PointerEventData eventData) { if (fadeTweener.IsRunning) { fadeTweener.CompleteInstantly(); } var tween = new FloatTween(CurrentOpacity, 1f - hoverOpacityFade, FadeTime, SetOpacity, true); fadeTweener.Run(tween); }
protected virtual void FadeOutSlot() { if (fadeTweener.Running) { fadeTweener.CompleteInstantly(); } var tween = new FloatTween(Opacity, 1f - hoverOpacityFade, FadeTime, SetOpacity, true, target: this); fadeTweener.Run(tween); }
public void FadeVolume(float volume, float time) { if (listenerVolumeTweener.IsRunning) { listenerVolumeTweener.CompleteInstantly(); } var tween = new FloatTween(Volume, volume, time, value => Volume = value, ignoreTimeScale: true); listenerVolumeTweener.Run(tween); }
public async Task FadeAsync(float volume, float fadeTime) { if (!IsValid) { return; } CompleteAllRunners(); var tween = new FloatTween(Volume, volume, fadeTime, v => Volume = v); await volumeTweener.RunAsync(tween); }
public async Task StopAsync(float fadeOutTime) { if (!IsValid) { return; } CompleteAllRunners(); var tween = new FloatTween(Volume, 0, fadeOutTime, volume => Volume = volume); stopTimer.Run(fadeOutTime); await volumeTweener.RunAsync(tween); }
public async Task PlayAsync(float fadeInTime) { if (!IsValid) { return; } CompleteAllRunners(); if (!IsPlaying) { Play(); } var tween = new FloatTween(0, Volume, fadeInTime, volume => Volume = volume); await volumeTweener.RunAsync(tween); }