返回介绍

AudioSource.spread 扩散

发布于 2019-12-18 15:37:24 字数 1876 浏览 1179 评论 0 收藏 0

JavaScript => public var spread: float;
C# => public float spread;

Description 描述

Sets the spread angle (in degrees) of a 3d stereo or multichannel sound in speaker space.

设置3d立体声或多声道扬声器的空间的扩散角度。

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。

JavaScript:

	// 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) {
		var audio = other.GetComponent.<AudioSource>();
 
		if(audio)
			audio.spread = 0;
	}
 
	function OnTriggerExit(other : Collider) {
		var audio = other.GetComponent.<AudioSource>();
 
		if(audio)
			audio.spread = 360;
	}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    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;
 
    }
}

AudioSource

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文