设置 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; } } }