Пример #1
0
 /// <summary>
 /// Stop playing.
 /// </summary>
 /// <param name="fadeDuration"></param>
 public override void Stop(float fadeDuration)
 {
     if (IsPlaying && fadeDuration > 0 && fadeWhen.IsFlagSet(FadeTarget.Stop))
     {
         _fadeTarget = FadeTarget.Stop;
         FadeOut(fadeDuration);
     }
     else
     {
         _audioSource.volume = isMuted ? 0 : _initialVolumeValue;
         _fadeProgress       = 1;
         StopInternal();
     }
 }
Пример #2
0
 /// <summary>
 /// Start playing.
 /// </summary>
 /// <param name="fadeDuration"></param>
 public override void Play(float fadeDuration)
 {
     if (!IsPlaying && fadeDuration > 0 && fadeWhen.IsFlagSet(FadeTarget.Play))
     {
         _fadeTarget = FadeTarget.Play;
         PlayInternal();
         FadeIn(fadeDuration);
     }
     else
     {
         _audioSource.volume = isMuted ? 0 : _initialVolumeValue;
         _fadeProgress       = 1;
         PlayInternal();
     }
 }
Пример #3
0
    void Awake()
    {
        var targets = GetComponentsInChildren <Graphic>();

        _targets = new FadeTarget[targets.Length];
        for (var i = 0; i < targets.Length; i++)
        {
            _targets[i] = new FadeTarget {
                graphic = targets[i], alpha = targets[i].color.a
            };
            var color = targets[i].color;
            color.a          = _fadeCurve.Evaluate(_invert.Value ? 1 : 0) * color.a;
            targets[i].color = color;
        }
    }
Пример #4
0
 /// <summary>
 ///  Toggle mute state.
 /// </summary>
 /// <param name="isMuted"></param>
 /// <param name="fadeDuration"></param>
 public override void Mute(bool isMuted, float fadeDuration)
 {
     if (isMuted && fadeDuration > 0 && fadeWhen.IsFlagSet(FadeTarget.Mute))
     {
         _fadeTarget = FadeTarget.Mute;
         FadeOut(fadeDuration);
     }
     else if (!isMuted && fadeDuration > 0 && fadeWhen.IsFlagSet(FadeTarget.UnMute))
     {
         _fadeTarget = FadeTarget.UnMute;
         FadeIn(fadeDuration);
     }
     else
     {
         _audioSource.volume = isMuted ? 0 : _initialVolumeValue;
         _fadeProgress       = 1;
         MuteInternal(isMuted);
     }
 }
 public GraphicScreenFadeEffect(Graphic graphic, FadeTarget fade, uint cycleDuration, int repeatTimes = 0, bool pingpong = false) : base(fade, cycleDuration, repeatTimes, pingpong)
 {
     Graphic = graphic;
 }
Пример #6
0
 public ScreenFadeEffect(FadeTarget fade, uint cycleDuration, int repeatTimes = 0, bool pingpong = false) : base(cycleDuration, repeatTimes, pingpong)
 {
     Fade = fade;
 }
Пример #7
0
 /// <summary>
 /// Pause/Unpause.
 /// </summary>
 /// <param name="isPaused"></param>
 /// <param name="fadeDuration"></param>
 public override void Pause(bool isPaused, float fadeDuration)
 {
     if (isPaused && fadeDuration > 0 && fadeWhen.IsFlagSet(FadeTarget.Pause))
     {
         _fadeTarget = FadeTarget.Pause;
         FadeOut(fadeDuration);
     }
     else if (!isPaused && fadeDuration > 0 && fadeWhen.IsFlagSet(FadeTarget.UnPause))
     {
         _fadeTarget = FadeTarget.UnPause;
         PauseInternal(false);
         FadeIn(fadeDuration);
     }
     else
     {
         _audioSource.volume = isMuted ? 0 : _initialVolumeValue;
         _fadeProgress = 1;
         PauseInternal(isPaused);
     }
 }
Пример #8
0
 /// <summary>
 /// Stop playing.
 /// </summary>
 /// <param name="fadeDuration"></param>
 public override void Stop(float fadeDuration)
 {
     if (IsPlaying && fadeDuration > 0 && fadeWhen.IsFlagSet(FadeTarget.Stop))
     {
         _fadeTarget = FadeTarget.Stop;
         FadeOut(fadeDuration);
     }
     else
     {
         _audioSource.volume = isMuted ? 0 : _initialVolumeValue;
         _fadeProgress = 1;
         StopInternal();
     }
 }
Пример #9
0
 /// <summary>
 /// Start playing.
 /// </summary>
 /// <param name="fadeDuration"></param>
 public override void Play(float fadeDuration)
 {
     if (!IsPlaying && fadeDuration > 0 && fadeWhen.IsFlagSet(FadeTarget.Play))
     {
         _fadeTarget = FadeTarget.Play;
         PlayInternal();
         FadeIn(fadeDuration);
     }
     else
     {
         _audioSource.volume = isMuted ? 0 : _initialVolumeValue;
         _fadeProgress = 1;
         PlayInternal();
     }
 }