Exemplo n.º 1
0
        public void stop(string _soundName)
        {
            ASSound _sound = find_by_name(_soundName);

            if (_sound != null)
            {
                _sound.source.Stop();
            }
        }
Exemplo n.º 2
0
        private ASSound find_by_name(string _soundName)
        {
            ASSound ret = Array.Find(pool,
                                     element => element.name == _soundName);

            if (ret == null)
            {
                //Debug.LogWarning("Sound: '" + _soundName + "' couldn't be played because it wasn't found.");
            }

            return(ret);
        }
Exemplo n.º 3
0
        // Play a sound from the pool
        public void Play(string _soundName)
        {
            ASSound     _sound  = find_by_name(_soundName);
            AudioSource _source = _sound.source;

            _source.clip   = _sound.sound;
            _source.volume = UnityEngine.Random.Range(_sound.baseVolume - _sound.volumeVariance, _sound.baseVolume + _sound.volumeVariance);
            _source.pitch  = UnityEngine.Random.Range(_sound.basePitch - _sound.pitchVariance, _sound.basePitch + _sound.pitchVariance);

            _source.spatialBlend = 0;

            if (_sound.mixer == null)
            {
                _source.outputAudioMixerGroup = masterMixer;
            }
            else
            {
                _source.outputAudioMixerGroup = _sound.mixer;
            }

            _source.Play();
        }