예제 #1
0
 public AudioClipHandle PlayAudio(int soundIdEnum, AudioClipHandle oldHandle)
 {
     StopAudio(oldHandle);
     return(PlayAudio(new PlayConfig {
         SoundID = _audioManagerHelper.AudioEnumToStringId(soundIdEnum)
     }));
 }
예제 #2
0
        private void PrepareForReuse()
        {
            StopAllCoroutines();

            m_FadeInData  = null;
            m_FadeOutData = null;

            cachedGameObject.name = "AudioClipPlayer";

            ClipID   = null;
            Category = null;

            m_Source.clip = null;
            m_Source.outputAudioMixerGroup = null;
            if (m_Handle != null)
            {
                m_Handle.Clear();
            }
            m_Handle = null;

            foreach (var kv in m_Filters)
            {
                kv.Value.enabled = false;
            }

            cachedTransform.position = Vector3.zero;

            IsEmpty = true;
        }
예제 #3
0
 public static AudioClipHandle ReleaseHandle(AudioClipHandle handle)
 {
     if (handle != null)
     {
         handle.StopAndRelease();
     }
     return(null);
 }
예제 #4
0
        public AudioClipHandle StopAudioFadeout(AudioClipHandle clipHandler, float fadeOut)
        {
            if (clipHandler == null)
            {
                D.AudioWarning("Trying to stop null AudioClipHandle!");
                return(null);
            }

            clipHandler.ChangeVolume(AnimationCurve.EaseInOut(0, 1, fadeOut, 0), fadeOut, true);
            return(null);
        }
예제 #5
0
        public AudioClipHandle StopAudio(AudioClipHandle clipHandler)
        {
            if (clipHandler == null)
            {
                D.AudioWarning("Trying to stop null AudioClipHandle!");
                return(null);
            }

            clipHandler.StopAndRelease();
            return(null);
        }
예제 #6
0
        public void SetClip(AudioClip clip, Transform trackObject, float releaseDelayGameTime, float releaseDelayRealTime, string triggerName)
        {
            IsEmpty = false;
            ClipID  = clip.name;
#if UNITY_EDITOR
            name = string.Format("{0} - {1}", triggerName, clip.name);
#endif
            m_Handle = new AudioClipHandle(this);

            if (trackObject != null)
            {
                StartCoroutine(TrackObjectCR(trackObject));
            }

            if (releaseDelayGameTime != 0 || releaseDelayRealTime != 0)
            {
                StartCoroutine(DelayedReleaseCR(releaseDelayGameTime, releaseDelayRealTime));
            }
        }
예제 #7
0
        public void SetAudioGroupsPaused(bool paused, List <AudioMixerGroup> includeGroups, List <AudioMixerGroup> excludeGroups)
        {
            foreach (GameObject go in m_AudioClipPlayerPool.RentedObjects)
            {
                if (go == null)
                {
                    continue;
                }

                AudioClipPlayer p = go.GetComponent <AudioClipPlayer>();
                if (p == null)
                {
                    continue;
                }

                AudioClipHandle handle = p.Handle;
                if (handle == null)
                {
                    continue;
                }

                bool shouldAffect = (excludeGroups == null || !excludeGroups.Contains(handle.MixerGroup));
                shouldAffect &= (includeGroups == null || includeGroups.Contains(handle.MixerGroup));

                if (shouldAffect)
                {
                    if (paused)
                    {
                        handle.Pause();
                    }
                    else
                    {
                        handle.UnPause();
                    }
                }
            }
        }