Beispiel #1
0
        /// <summary>
        /// Plays an audio clip, only use this for the UI, it is not pooled so performance isn't superb.
        /// </summary>
        public static void AudioPlayOneShot(AudioClipInfo clip)
        {
            if (clip == null || clip.audioClip == null)
            {
                return;
            }

            if (Instance == null)
            {
                DevdogLogger.LogWarning("AudioManager not found, yet trying to play an audio clip....");
            }
        }
Beispiel #2
0
        private static AudioSource GetNextAudioSource()
        {
            foreach (var audioSource in _audioSources)
            {
                if (audioSource.isPlaying == false)
                {
                    return(audioSource);
                }
            }

            DevdogLogger.LogWarning("All sources taken, can't play audio clip...");
            return(null);
        }
        private string ToString(string msg, object[] vars)
        {
            try
            {
                return(string.Format(msg, vars));
            }
            catch (Exception)
            {
                DevdogLogger.LogWarning("Invalid string.Format :: " + msg);
            }

            return(msg);
        }
        private static AudioSource GetNextAudioSource()
        {
            foreach (var audioSource in _audioSources)
            {
                if (audioSource.isPlaying == false)
                {
                    return(audioSource);
                }
            }

            DevdogLogger.LogWarning("All sources taken, creating new on the fly... Consider increasing reserved audio sources");

            var src = CreateNewAudioSource();

            _audioSources.Add(src);
            return(src);
        }
        /// <summary>
        /// Plays an audio clip, only use this for the UI, it is not pooled so performance isn't superb.
        /// </summary>
        public static void AudioPlayOneShot(AudioClipInfo clip)
        {
            if (clip == null || clip.audioClip == null)
            {
                return;
            }

            if (instance == null)
            {
                DevdogLogger.LogWarning("AudioManager not found, yet trying to play an audio clip....");
            }

            if (_audioQueue.Any(o => o.audioClip == clip.audioClip) == false)
            {
                _audioQueue.Enqueue(clip);
            }
        }