Beispiel #1
0
        private void Start()
        {
            _soundEvent          = SoundAccess.GetInstance().RetrieveSoundEvent(key);
            _soundEventInstances = new List <SoundEventInstance>();

            for (int i = 0; i < _soundEvent.audioClips.Count; i++)
            {
                _soundEventInstances.Add(SoundEventInstanceManager.GetInstance().CreateSoundEventInstance(gameObject, _soundEvent));
            }

            foreach (SoundEventInstance soundEventInstance in _soundEventInstances)
            {
                soundEventInstance.SetVolume(0);
            }

            if (playOnStart)
            {
                CrossFadeTo(0, 0);
            }
        }
Beispiel #2
0
        public void Play()
        {
            SoundEvent soundEvent = SoundAccess.GetInstance().RetrieveSoundEvent(key);

            RemoveOldEventInstanceIfKeyHasChanged();

            if (!SoundEventInstanceManager.GetInstance().IsAllowedToPlay(soundEvent))
            {
                return;
            }

            if (_soundEventInstance)
            {
                _soundEventInstance.Play();
                return;
            }

            _soundEventInstance = SoundEventInstanceManager.GetInstance().CreateSoundEventInstance(gameObject, soundEvent);
            _soundEventInstance.Play();
        }
Beispiel #3
0
 private void OnDestroy()
 {
     SoundEventInstanceManager.GetInstance().Unregister(this);
     Destroy(_audioSource);
 }