public void Play(AudioBlock audioBlock, Vector3 position, bool usePosition) { AudioChannel channel = audioBlock.AudioChannel; if (channel == null) { Debug.LogError($"AudioBlock {audioBlock.name} failed to play. It does not have a valid AudioChannel.", audioBlock); return; } if (this.audioChannelsIntanceIds.Contains(channel.GetInstanceID()) == false) { Debug.LogError($"AudioBlock {audioBlock.name} failed to play because it's AudioChannel {channel.name} Is not registered with the AudioManager.", audioBlock); return; } if (channel.IsMuted || channel.Volume == 0.0f) { return; } AudioSource audioSource = this.GetAudioSource(); audioSource.gameObject.SetActive(true); audioSource.transform.position = position; audioSource.spatialBlend = usePosition ? 1.0f : 0.0f; audioSource.clip = audioBlock.GetAudioClip(); audioSource.pitch = audioBlock.GetPitch(); audioSource.volume = audioBlock.GetVolume() * channel.Volume; audioSource.Play(); }
public void Play(AudioBlock audioBlock, Vector3 position) { this.Play(audioBlock, position, true); }
public void Play(AudioBlock audioBlock) { this.Play(audioBlock, Vector3.zero, false); }