Beispiel #1
0
        public AudioOneShotPlayer PlayOneShotAtPosition(AudioClip clip, Vector3 position, float volumeMultiplier = 1)
        {
            Vector2 delta = position - Listener.transform.position;

            if (delta.sqrMagnitude > soundInRange * soundInRange)
            {
                return(null);
            }

            AudioOneShotPlayer player = oneShotPlayerPool.Get();

            player.transform.position = position;
            player.Play(clip, (_player) => oneShotPlayerPool.Put(_player), volumeMultiplier);
            return(player);
        }
Beispiel #2
0
        public AudioOneShotPlayer PlayOneShotAtPosition(AudioIDEnum ID, Vector3 position, float volumeMultiplier = 1)
        {
            if (!clipDicts.ContainsKey(ID))
            {
            #if UNITY_EDITOR
                Debug.LogWarningFormat("Audio '{0}' doesn't exist", ID);
            #endif
                return(null);
            }

            Vector2 delta = position - Listener.transform.position;
            if (delta.sqrMagnitude > soundInRange * soundInRange)
            {
                return(null);
            }

            AudioOneShotPlayer player = oneShotPlayerPool.Get();
            player.transform.position = position;
            player.Play(clipDicts[ID].Clip, (_player) => oneShotPlayerPool.Put(_player), clipDicts[ID].Volume * volumeMultiplier);
            return(player);
        }