コード例 #1
0
        /// <summary>
        /// Fade in and play the audio (from an audio config).
        /// </summary>
        /// <param name="audioConfig">The target audio config</param>
        /// <param name="duration">Duration of the fade in phase</param>
        /// <param name="parent">The source of the audio</param>
        /// <param name="onComplete">Callback after the fade in completed</param>
        /// <returns></returns>
        public static AudioSource FadeInAndPlay(this AudioConfig audioConfig, float duration = 1.0f, Transform parent = null, Action onComplete = null)
        {
            var channel = audioConfig.Play(0f, parent);

            AudioSystem.Instance.FadeTo(channel, audioConfig.VolumeScale, duration, onComplete);
            return(channel);
        }
コード例 #2
0
 /// <summary>
 /// Play an audio clip by using an Audio Config
 /// </summary>
 /// <param name="audioConfig">The target audio config</param>
 /// <param name="parent">The source of the audio</param>
 /// <param name="onComplete">The callback when the playback finished</param>
 /// <returns>The channel (AudioSource) which the Audio System are using</returns>
 public static AudioSource Play(this AudioConfig audioConfig, Transform parent, int clipIndex = -1, Action onComplete = null)
 {
     return(audioConfig.Play(audioConfig.VolumeScale, parent, clipIndex, onComplete));
 }
コード例 #3
0
 /// <summary>
 /// Play an audio clip by using an Audio Config
 /// </summary>
 /// <param name="audioConfig">The target audio config</param>
 /// <param name="onComplete">The callback when the playback finished</param>
 /// <returns>The channel (AudioSource) which the Audio System are using</returns>
 public static AudioSource Play(this AudioConfig audioConfig, Action onComplete = null)
 {
     return(audioConfig.Play(audioConfig.VolumeScale, null, onComplete: onComplete));
 }