返回介绍

AudioSource 音频源

发布于 2019-12-18 15:37:23 字数 11884 浏览 1485 评论 0 收藏 0

class in UnityEngine / Inherits from: Behaviour

Description 描述

A representation of audio sources in 3D.

在3d空间内表示一个声音资源。

An AudioSource is attached to a GameObject for playing back sounds in a 3D environment. In order to play 3D sounds you also need to have a AudioListener. The audio listener is normally attached to the camera you want to use. Whether sounds are played in 3D or 2D is determined by AudioImporter settings.

一个绑定在游戏对象上的AudioSource组件是用来在3d环境中播放声音的。 为了让这个声音被听到,你还需要一个AudioListener组件。AudioListener组件通常绑定到你想要使用的Camera上。这个声音资源是3D音效还是2D音效,是由AudioImporter来设置决定的。

You can play a single audio clip using Play, Pause and Stop. You can also adjust its volume while playing using the volume property, or seek using time. Multiple sounds can be played on one AudioSource using PlayOneShot. You can play a clip at a static position in 3D space using PlayClipAtPoint.

你可以控制这个声音片段用Play,Pause和Stop。你也可以在音频播放的时候用volume属性调整音量,或者查看播放时间。多个声音片段也可以用PlayOneShot在同一个AudioSource中播放。您可以使用PlayClipAtPoint在三维空间中的固定位置播放声音片段。

See Also: AudioListener, AudioClip, AudioSource component.

Variables 变量

bypassEffectsBypass effects (Applied from filter components or global listener filters).
直通效果(应用过滤器组件或全局监听过滤器)。
bypassListenerEffectsWhen set global effects on the AudioListener will not be applied to the audio signal generated by the AudioSource. Does not apply if the AudioSource is playing into a mixer group.
当在AudioListener设置全局效果,将不会应用到由AudioSource生成的音频信号。如果AudioSource正在混合器组播放,将不会被应用。
bypassReverbZonesWhen set doesn't route the signal from an AudioSource into the global reverb associated with reverb zones.
当设置AudioSource无路由信号到与混响区域关联的全局混响时。
clipThe default AudioClip to play.
默认要播放的音频剪辑。
dopplerLevelSets the Doppler scale for this AudioSource.
设置该AudioSource的多普勒大小。
ignoreListenerPauseAllows AudioSource to play even though AudioListener.pause is set to true. This is useful for the menu element sounds or background music in pause menus.
允许AudioListener.pause属性被设置为true的时候依然允许AudioSource播放。这个通常用于菜单项声音或者背景音乐的暂停功能。
ignoreListenerVolumeThis makes the audio source not take into account the volume of the audio listener.
这个使得AudioSource不受AudioListener组件音量值的影响。
isPlayingIs the clip playing right now (Read Only)?
该音频剪辑是否正播放(只读)?
loopIs the audio clip looping?
该音频剪辑是否循环?
maxDistance(Logarithmic rolloff) MaxDistance is the distance a sound stops attenuating at.
(对数衰减)最大距离是一个声音停止衰减的距离。
minDistanceWithin the Min distance the AudioSource will cease to grow louder in volume.
在最小距离内,AudioSource将停止增大音量。
muteUn- / Mutes the AudioSource. Mute sets the volume=0, Un-Mute restore the original volume.
是否静音音频源。Mute是设置音量为0,取消静音是恢复原来的音量。
outputAudioMixerGroupThe target group to which the AudioSource should route its signal.
AudioSource应该路由的目标组信号。
panStereoPans a playing sound in a stereo way (left or right). This only applies to sounds that are Mono or Stereo.
以立体声方式声像一个正播放的声音(左或右),这仅用于单声道或立体声。
pitchThe pitch of the audio source.
音频源的音调。
playOnAwakeIf set to true, the audio source will automatically start playing on awake.
如果设置为true,音频源将在唤醒时自动播放。
prioritySets the priority of the AudioSource.
设置AudioSource的优先级。
reverbZoneMixThe amount by which the signal from the AudioSource will be mixed into the global reverb associated with the Reverb Zones.
信号来自AudioSource将混合到有关混响区全局混响的数量。
rolloffModeSets/Gets how the AudioSource attenuates over distance.
设置/获取AudioSource随着距离怎样衰减。
spatialBlendSets how much this AudioSource is affected by 3D spatialisation calculations (attenuation, doppler etc). 0.0 makes the sound full 2D, 1.0 makes it full 3D.
设置该音频源由3D空间计算(衰减,多普勒等)被影响多少。0.0使声音完全2D,1.0使声音完全3D。
spatializeEnables or disables spatialization.
启用或禁用空间化。
spreadSets the spread angle (in degrees) of a 3d stereo or multichannel sound in speaker space.
设置3d立体声或多声道扬声器的空间的扩散角度。
timePlayback position in seconds.
以秒为单位的播放位置。
timeSamplesPlayback position in PCM samples.
在PCM取样的播放位置。
velocityUpdateModeWhether the Audio Source should be updated in the fixed or dynamic update.
AudioSource是否应该以固定或动态的方式更新?
volumeThe volume of the audio source (0.0 to 1.0).
音频源的音量(0.0 ~ 1.0)。

Public Functions 共有函数

GetCustomCurveGet the current custom curve for the given AudioSourceCurveType.
获取给定AudioSourceCurveType类型的当前自定义曲线。
GetSpatializerFloatReads a user-defined parameter of a custom spatializer effect that is attached to an AudioSource.
读取附加到音频源的自定义空间化效果的一个用户自定义参数。
PausePauses playing the clip.
暂停正播放的音频剪辑。
PlayPlays the clip with an optional certain delay.
播放音频剪辑,带有可选延迟参数。
PlayDelayedPlays the clip with a delay specified in seconds. Users are advised to use this function instead of the old Play(delay) function that took a delay specified in samples relative to a reference rate of 44.1 kHz as an argument.
播放一个带有指定延迟的音频剪辑,单位秒。建议用户替代老函数Play(delay),接受指定采样相对于44.1 kHz参考速率作为参数延迟。
PlayOneShotPlays an AudioClip, and scales the AudioSource volume by volumeScale.
播放一个音频剪辑,并且通过volumeScale缩放音频源音量。
PlayScheduledPlays the clip at a specific time on the absolute time-line that AudioSettings.dspTime reads from.
在指定的时间播放剪辑,时间是读取AudioSettings.dspTime绝对时间线。
SetCustomCurveSet the custom curve for the given AudioSourceCurveType.
设置给定AudioSourceCurveType类型的自定义曲线。
SetScheduledEndTimeChanges the time at which a sound that has already been scheduled to play will end. Notice that depending on the timing not all rescheduling requests can be fulfilled.
更改已定时播放的声音将结束的时间。注意取决于时间,不是所有的重定时请求被满足。
SetScheduledStartTimeChanges the time at which a sound that has already been scheduled to play will start.
更改已定时播放的声音将开始的时间。
SetSpatializerFloatSets a user-defined parameter of a custom spatializer effect that is attached to an AudioSource.
设置一个附加到音频源的自定义空间化效果的一个用户自定义参数。
StopStops playing the clip.
停止播放该剪辑。
UnPauseUnpause the paused playback of this AudioSource.
取消该音频源已暂停的播放。

Static Functions 静态函数

PlayClipAtPointPlays an AudioClip at a given position in world space.
在世界空间给定位置播放一个音频剪辑。

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

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

发布评论

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