Version: 2021.2
public float spread ;

描述

设置扬声器空间中 3D 立体声或多声道声音的扩散角度(以度为单位)。

0 = 所有声道都位于同一个扬声器位置并且为“单声道”。360 = 所有子通道都位于与根据 3D 位置确定的扬声器位置相对的扬声器位置。默认为 0。

using UnityEngine;

public class Example : MonoBehaviour { // when any AudioSource goes trough this transform, it will set it as 'mono' // and will restore the value to 3D effect after exiting // Make sure the audio source has a collider. void OnTriggerEnter(Collider other) { AudioSource audio = other.GetComponent<AudioSource>();

if (audio) { audio.spread = 0; } }

void OnTriggerExit(Collider other) { AudioSource audio = other.GetComponent<AudioSource>();

if (audio) { audio.spread = 360; } } }