| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 | 
							- // Author: Daniele Giardini - http://www.demigiant.com
 
- // Created: 2018/07/13
 
- #if true // MODULE_MARKER
 
- using System;
 
- using DG.Tweening.Core;
 
- using DG.Tweening.Plugins.Options;
 
- using UnityEngine;
 
- using UnityEngine.Audio; // Required for AudioMixer
 
- #pragma warning disable 1591
 
- namespace DG.Tweening
 
- {
 
- 	public static class DOTweenModuleAudio
 
-     {
 
-         #region Shortcuts
 
-         #region Audio
 
-         /// <summary>Tweens an AudioSource's volume to the given value.
 
-         /// Also stores the AudioSource as the tween's target so it can be used for filtered operations</summary>
 
-         /// <param name="endValue">The end value to reach (0 to 1)</param><param name="duration">The duration of the tween</param>
 
-         public static TweenerCore<float, float, FloatOptions> DOFade(this AudioSource target, float endValue, float duration)
 
-         {
 
-             if (endValue < 0) endValue = 0;
 
-             else if (endValue > 1) endValue = 1;
 
-             TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.volume, x => target.volume = x, endValue, duration);
 
-             t.SetTarget(target);
 
-             return t;
 
-         }
 
-         /// <summary>Tweens an AudioSource's pitch to the given value.
 
-         /// Also stores the AudioSource as the tween's target so it can be used for filtered operations</summary>
 
-         /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 
-         public static TweenerCore<float, float, FloatOptions> DOPitch(this AudioSource target, float endValue, float duration)
 
-         {
 
-             TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.pitch, x => target.pitch = x, endValue, duration);
 
-             t.SetTarget(target);
 
-             return t;
 
-         }
 
-         #endregion
 
-         #region AudioMixer
 
-         /// <summary>Tweens an AudioMixer's exposed float to the given value.
 
-         /// Also stores the AudioMixer as the tween's target so it can be used for filtered operations.
 
-         /// Note that you need to manually expose a float in an AudioMixerGroup in order to be able to tween it from an AudioMixer.</summary>
 
-         /// <param name="floatName">Name given to the exposed float to set</param>
 
-         /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 
-         public static TweenerCore<float, float, FloatOptions> DOSetFloat(this AudioMixer target, string floatName, float endValue, float duration)
 
-         {
 
-             TweenerCore<float, float, FloatOptions> t = DOTween.To(()=> {
 
-                     float currVal;
 
-                     target.GetFloat(floatName, out currVal);
 
-                     return currVal;
 
-                 }, x=> target.SetFloat(floatName, x), endValue, duration);
 
-             t.SetTarget(target);
 
-             return t;
 
-         }
 
-         #region Operation Shortcuts
 
-         /// <summary>
 
-         /// Completes all tweens that have this target as a reference
 
-         /// (meaning tweens that were started from this target, or that had this target added as an Id)
 
-         /// and returns the total number of tweens completed
 
-         /// (meaning the tweens that don't have infinite loops and were not already complete)
 
-         /// </summary>
 
-         /// <param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
 
-         /// otherwise they will be ignored</param>
 
-         public static int DOComplete(this AudioMixer target, bool withCallbacks = false)
 
-         {
 
-             return DOTween.Complete(target, withCallbacks);
 
-         }
 
-         /// <summary>
 
-         /// Kills all tweens that have this target as a reference
 
-         /// (meaning tweens that were started from this target, or that had this target added as an Id)
 
-         /// and returns the total number of tweens killed.
 
-         /// </summary>
 
-         /// <param name="complete">If TRUE completes the tween before killing it</param>
 
-         public static int DOKill(this AudioMixer target, bool complete = false)
 
-         {
 
-             return DOTween.Kill(target, complete);
 
-         }
 
-         /// <summary>
 
-         /// Flips the direction (backwards if it was going forward or viceversa) of all tweens that have this target as a reference
 
-         /// (meaning tweens that were started from this target, or that had this target added as an Id)
 
-         /// and returns the total number of tweens flipped.
 
-         /// </summary>
 
-         public static int DOFlip(this AudioMixer target)
 
-         {
 
-             return DOTween.Flip(target);
 
-         }
 
-         /// <summary>
 
-         /// Sends to the given position all tweens that have this target as a reference
 
-         /// (meaning tweens that were started from this target, or that had this target added as an Id)
 
-         /// and returns the total number of tweens involved.
 
-         /// </summary>
 
-         /// <param name="to">Time position to reach
 
-         /// (if higher than the whole tween duration the tween will simply reach its end)</param>
 
-         /// <param name="andPlay">If TRUE will play the tween after reaching the given position, otherwise it will pause it</param>
 
-         public static int DOGoto(this AudioMixer target, float to, bool andPlay = false)
 
-         {
 
-             return DOTween.Goto(target, to, andPlay);
 
-         }
 
-         /// <summary>
 
-         /// Pauses all tweens that have this target as a reference
 
-         /// (meaning tweens that were started from this target, or that had this target added as an Id)
 
-         /// and returns the total number of tweens paused.
 
-         /// </summary>
 
-         public static int DOPause(this AudioMixer target)
 
-         {
 
-             return DOTween.Pause(target);
 
-         }
 
-         /// <summary>
 
-         /// Plays all tweens that have this target as a reference
 
-         /// (meaning tweens that were started from this target, or that had this target added as an Id)
 
-         /// and returns the total number of tweens played.
 
-         /// </summary>
 
-         public static int DOPlay(this AudioMixer target)
 
-         {
 
-             return DOTween.Play(target);
 
-         }
 
-         /// <summary>
 
-         /// Plays backwards all tweens that have this target as a reference
 
-         /// (meaning tweens that were started from this target, or that had this target added as an Id)
 
-         /// and returns the total number of tweens played.
 
-         /// </summary>
 
-         public static int DOPlayBackwards(this AudioMixer target)
 
-         {
 
-             return DOTween.PlayBackwards(target);
 
-         }
 
-         /// <summary>
 
-         /// Plays forward all tweens that have this target as a reference
 
-         /// (meaning tweens that were started from this target, or that had this target added as an Id)
 
-         /// and returns the total number of tweens played.
 
-         /// </summary>
 
-         public static int DOPlayForward(this AudioMixer target)
 
-         {
 
-             return DOTween.PlayForward(target);
 
-         }
 
-         /// <summary>
 
-         /// Restarts all tweens that have this target as a reference
 
-         /// (meaning tweens that were started from this target, or that had this target added as an Id)
 
-         /// and returns the total number of tweens restarted.
 
-         /// </summary>
 
-         public static int DORestart(this AudioMixer target)
 
-         {
 
-             return DOTween.Restart(target);
 
-         }
 
-         /// <summary>
 
-         /// Rewinds all tweens that have this target as a reference
 
-         /// (meaning tweens that were started from this target, or that had this target added as an Id)
 
-         /// and returns the total number of tweens rewinded.
 
-         /// </summary>
 
-         public static int DORewind(this AudioMixer target)
 
-         {
 
-             return DOTween.Rewind(target);
 
-         }
 
-         /// <summary>
 
-         /// Smoothly rewinds all tweens that have this target as a reference
 
-         /// (meaning tweens that were started from this target, or that had this target added as an Id)
 
-         /// and returns the total number of tweens rewinded.
 
-         /// </summary>
 
-         public static int DOSmoothRewind(this AudioMixer target)
 
-         {
 
-             return DOTween.SmoothRewind(target);
 
-         }
 
-         /// <summary>
 
-         /// Toggles the paused state (plays if it was paused, pauses if it was playing) of all tweens that have this target as a reference
 
-         /// (meaning tweens that were started from this target, or that had this target added as an Id)
 
-         /// and returns the total number of tweens involved.
 
-         /// </summary>
 
-         public static int DOTogglePause(this AudioMixer target)
 
-         {
 
-             return DOTween.TogglePause(target);
 
-         }
 
-         #endregion
 
-         #endregion
 
-         #endregion
 
-     }
 
- }
 
- #endif
 
 
  |