< Summary

Class:DG.Tweening.DOTweenModuleAudio
Assembly:DOTween.Modules
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Plugins/DOTween/Modules/DOTweenModuleAudio.cs
Covered lines:0
Uncovered lines:26
Coverable lines:26
Total lines:202
Line coverage:0% (0 of 26)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DOFade(...)0%12300%
DOPitch(...)0%2100%
DOSetFloat(...)0%2100%
DOComplete(...)0%2100%
DOKill(...)0%2100%
DOFlip(...)0%2100%
DOGoto(...)0%2100%
DOPause(...)0%2100%
DOPlay(...)0%2100%
DOPlayBackwards(...)0%2100%
DOPlayForward(...)0%2100%
DORestart(...)0%2100%
DORewind(...)0%2100%
DOSmoothRewind(...)0%2100%
DOTogglePause(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Plugins/DOTween/Modules/DOTweenModuleAudio.cs

#LineLine coverage
 1// Author: Daniele Giardini - http://www.demigiant.com
 2// Created: 2018/07/13
 3
 4#if true // MODULE_MARKER
 5using System;
 6using DG.Tweening.Core;
 7using DG.Tweening.Plugins.Options;
 8using UnityEngine;
 9#if UNITY_5 || UNITY_2017_1_OR_NEWER
 10using UnityEngine.Audio; // Required for AudioMixer
 11#endif
 12
 13#pragma warning disable 1591
 14namespace DG.Tweening
 15{
 16  public static class DOTweenModuleAudio
 17    {
 18        #region Shortcuts
 19
 20        #region Audio
 21
 22        /// <summary>Tweens an AudioSource's volume to the given value.
 23        /// Also stores the AudioSource as the tween's target so it can be used for filtered operations</summary>
 24        /// <param name="endValue">The end value to reach (0 to 1)</param><param name="duration">The duration of the twe
 25        public static TweenerCore<float, float, FloatOptions> DOFade(this AudioSource target, float endValue, float dura
 26        {
 027            if (endValue < 0) endValue = 0;
 028            else if (endValue > 1) endValue = 1;
 029            TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.volume, x => target.volume = x, endValue
 030            t.SetTarget(target);
 031            return t;
 32        }
 33
 34        /// <summary>Tweens an AudioSource's pitch to the given value.
 35        /// Also stores the AudioSource as the tween's target so it can be used for filtered operations</summary>
 36        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 37        public static TweenerCore<float, float, FloatOptions> DOPitch(this AudioSource target, float endValue, float dur
 38        {
 039            TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.pitch, x => target.pitch = x, endValue, 
 040            t.SetTarget(target);
 041            return t;
 42        }
 43
 44        #endregion
 45
 46#if UNITY_5 || UNITY_2017_1_OR_NEWER
 47        #region AudioMixer (Unity 5 or Newer)
 48
 49        /// <summary>Tweens an AudioMixer's exposed float to the given value.
 50        /// Also stores the AudioMixer as the tween's target so it can be used for filtered operations.
 51        /// Note that you need to manually expose a float in an AudioMixerGroup in order to be able to tween it from an 
 52        /// <param name="floatName">Name given to the exposed float to set</param>
 53        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 54        public static TweenerCore<float, float, FloatOptions> DOSetFloat(this AudioMixer target, string floatName, float
 55        {
 056            TweenerCore<float, float, FloatOptions> t = DOTween.To(()=> {
 57                    float currVal;
 058                    target.GetFloat(floatName, out currVal);
 059                    return currVal;
 060                }, x=> target.SetFloat(floatName, x), endValue, duration);
 061            t.SetTarget(target);
 062            return t;
 63        }
 64
 65        #region Operation Shortcuts
 66
 67        /// <summary>
 68        /// Completes all tweens that have this target as a reference
 69        /// (meaning tweens that were started from this target, or that had this target added as an Id)
 70        /// and returns the total number of tweens completed
 71        /// (meaning the tweens that don't have infinite loops and were not already complete)
 72        /// </summary>
 73        /// <param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
 74        /// otherwise they will be ignored</param>
 75        public static int DOComplete(this AudioMixer target, bool withCallbacks = false)
 76        {
 077            return DOTween.Complete(target, withCallbacks);
 78        }
 79
 80        /// <summary>
 81        /// Kills all tweens that have this target as a reference
 82        /// (meaning tweens that were started from this target, or that had this target added as an Id)
 83        /// and returns the total number of tweens killed.
 84        /// </summary>
 85        /// <param name="complete">If TRUE completes the tween before killing it</param>
 86        public static int DOKill(this AudioMixer target, bool complete = false)
 87        {
 088            return DOTween.Kill(target, complete);
 89        }
 90
 91        /// <summary>
 92        /// Flips the direction (backwards if it was going forward or viceversa) of all tweens that have this target as 
 93        /// (meaning tweens that were started from this target, or that had this target added as an Id)
 94        /// and returns the total number of tweens flipped.
 95        /// </summary>
 96        public static int DOFlip(this AudioMixer target)
 97        {
 098            return DOTween.Flip(target);
 99        }
 100
 101        /// <summary>
 102        /// Sends to the given position all tweens that have this target as a reference
 103        /// (meaning tweens that were started from this target, or that had this target added as an Id)
 104        /// and returns the total number of tweens involved.
 105        /// </summary>
 106        /// <param name="to">Time position to reach
 107        /// (if higher than the whole tween duration the tween will simply reach its end)</param>
 108        /// <param name="andPlay">If TRUE will play the tween after reaching the given position, otherwise it will pause
 109        public static int DOGoto(this AudioMixer target, float to, bool andPlay = false)
 110        {
 0111            return DOTween.Goto(target, to, andPlay);
 112        }
 113
 114        /// <summary>
 115        /// Pauses all tweens that have this target as a reference
 116        /// (meaning tweens that were started from this target, or that had this target added as an Id)
 117        /// and returns the total number of tweens paused.
 118        /// </summary>
 119        public static int DOPause(this AudioMixer target)
 120        {
 0121            return DOTween.Pause(target);
 122        }
 123
 124        /// <summary>
 125        /// Plays all tweens that have this target as a reference
 126        /// (meaning tweens that were started from this target, or that had this target added as an Id)
 127        /// and returns the total number of tweens played.
 128        /// </summary>
 129        public static int DOPlay(this AudioMixer target)
 130        {
 0131            return DOTween.Play(target);
 132        }
 133
 134        /// <summary>
 135        /// Plays backwards all tweens that have this target as a reference
 136        /// (meaning tweens that were started from this target, or that had this target added as an Id)
 137        /// and returns the total number of tweens played.
 138        /// </summary>
 139        public static int DOPlayBackwards(this AudioMixer target)
 140        {
 0141            return DOTween.PlayBackwards(target);
 142        }
 143
 144        /// <summary>
 145        /// Plays forward all tweens that have this target as a reference
 146        /// (meaning tweens that were started from this target, or that had this target added as an Id)
 147        /// and returns the total number of tweens played.
 148        /// </summary>
 149        public static int DOPlayForward(this AudioMixer target)
 150        {
 0151            return DOTween.PlayForward(target);
 152        }
 153
 154        /// <summary>
 155        /// Restarts all tweens that have this target as a reference
 156        /// (meaning tweens that were started from this target, or that had this target added as an Id)
 157        /// and returns the total number of tweens restarted.
 158        /// </summary>
 159        public static int DORestart(this AudioMixer target)
 160        {
 0161            return DOTween.Restart(target);
 162        }
 163
 164        /// <summary>
 165        /// Rewinds all tweens that have this target as a reference
 166        /// (meaning tweens that were started from this target, or that had this target added as an Id)
 167        /// and returns the total number of tweens rewinded.
 168        /// </summary>
 169        public static int DORewind(this AudioMixer target)
 170        {
 0171            return DOTween.Rewind(target);
 172        }
 173
 174        /// <summary>
 175        /// Smoothly rewinds all tweens that have this target as a reference
 176        /// (meaning tweens that were started from this target, or that had this target added as an Id)
 177        /// and returns the total number of tweens rewinded.
 178        /// </summary>
 179        public static int DOSmoothRewind(this AudioMixer target)
 180        {
 0181            return DOTween.SmoothRewind(target);
 182        }
 183
 184        /// <summary>
 185        /// Toggles the paused state (plays if it was paused, pauses if it was playing) of all tweens that have this tar
 186        /// (meaning tweens that were started from this target, or that had this target added as an Id)
 187        /// and returns the total number of tweens involved.
 188        /// </summary>
 189        public static int DOTogglePause(this AudioMixer target)
 190        {
 0191            return DOTween.TogglePause(target);
 192        }
 193
 194        #endregion
 195
 196        #endregion
 197#endif
 198
 199        #endregion
 200    }
 201}
 202#endif