示例#1
0
        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);
        }
示例#3
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }