Beispiel #1
0
        public static SoundEventInstanceManager GetInstance()
        {
            if (_instance == null)
            {
                _instance = new SoundEventInstanceManager();
            }

            return(_instance);
        }
Beispiel #2
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 #3
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 #4
0
 private void OnDestroy()
 {
     SoundEventInstanceManager.GetInstance().Unregister(this);
     Destroy(_audioSource);
 }