AudioSource.spread 扩散
var spread : float
Description描述
Sets the spread angle a 3d stereo or multichannel sound in speaker space.
设置3d stereo的扩散角或扬声器空间的多声道声音。
0 = all sound channels are located at the same speaker location and is 'mono'. 360 = all subchannels are located at the opposite speaker location to the speaker location that it should be according to 3D position. Default = 0.
0=所有声音通道位于相同的扬声器位置并且是单声道。360=所有子通道位于对面扬声器的位置到扬声器位置,这应该根据3D位置。默认为0。
C#
JavaScript
using UnityEngine;using System.Collections;public class example : MonoBehaviour {void OnTriggerEnter(Collider other) {if (other.audio)other.audio.spread = 0;}void OnTriggerExit(Collider other) {if (other.audio)other.audio.spread = 360;}}
// 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.//当任意AudioSource通过这个变换,将设置它为单通道,并且退出后恢复值到3D效果//确定音频源有一个碰撞器function OnTriggerEnter(other : Collider) {if(other.audio)other.audio.spread = 0;}function OnTriggerExit(other : Collider) {if(other.audio)other.audio.spread = 360;}