Unity API 文档之Audio Source

Audio Source

音频资源

The Audio Source plays back an Audio Clip in the scene. If the Audio Clip is a 3D clip, the source is played back at

在场景中音频剪辑回放。如果音频剪辑资源是3D的,这个资源在指定的位置回放,

 a given position and will attenuate over distance. The audio can be spread out between speakers (stereo to 7.1)

并将随着距离减弱。音频可以分散在扬声器(立体声7.1)(传播)

 (Spread) and morphed between 3D and 2D (PanLevel). This can be controlled over distance with falloff curves.

和可以在3D和2D效果之间转换(平衡调整级别)。这是可以控制的随距离减弱的曲线。

 Also, if thelistener is within one or multiple Reverb Zones, reverberations is applied to the source. (PRO only)

此外,如果监听器是在1个或多个混响区。回响将会应用到音频源。(只有PRO版可用)

 Individual filters can be applied to each audio source for an even richer audio experience. See Audio Effects for more details.

单独的过滤器可以应用到每一个音频源,可以得到更丰富的音频体验。更多资料请参考Audio Effects.



The Audio Source gizmo in the Scene View and its settings in the inspector.
音频源在场景视图中gizmo和它在检视面板中的设置

Properties

属性

Audio Clip

音频剪辑

Reference to the sound clip file that will be played.

将被播放的音频剪辑成文件

Mute

静音

If enabled the sound will be playing but muted.

如果开启,音频将被播放但没有声音

Bypass Effects

环绕效果

This Is to quickly "by-pass" filter effects applied to the audio source. An easy way to turn all effects on/off.

引用到音频源的快速"环绕"过滤效果,一个简单的方法来打开、关闭所有特效。

Play On Awake

唤醒时播放

If enabled, the sound will start playing the moment the scene launches. If disabled, you need to start it using the Play() command from scripting.

如果开启,声音将在进入场景时播放,如果禁止,你需要在脚本中使用Play()命令来开启它。

Loop

循环

Enable this to make the Audio Clip loop when it reaches the end.

开启这个属性将在播放结束后循环播放音频剪辑文件。

Priority

优先级

Determines the priority of this audio source among all the ones that coexist in the scene. (Priority: 0 = most important. 256 = least important. Default = 128.). Use 0 for music tracks to avoid it getting occasionally swapped out.

确定场景中所有并存的音频源之间的优先权。(0=最高优先权。256 = 最低优先权,128 = 默认优先权)使用0的乐曲可以避免偶尔被更换。


Volume

音量

How loud the sound is at a distance of one world unit (one meter) from the Audio Listener.

声音从音频监听器1个世界单位(1米)有多大声音

Pitch

音调

Amount of change in pitch due to slowdown/speed up of the Audio Clip. Value 1 is normal playback speed.

改变音调值,可以减速/加速音频剪辑的播放。1是正常的播放速度。

3D Sound Settings

3D音效设置

Settings that are applied to the audio source if the Audio Clip is a 3D Sound.

如果一个3D的声音,应用到音频源的设置

Pan Level

平衡调整级别

Sets how much the 3d engine has an effect on the audio source.

设置多少,3D引擎在音频源上有效果。

Spread

扩散

Sets the spread angle to 3d stereo or multichannel sound in speaker space.

设置3D立体声或者多声道音响在扬声器空间的传播角度。

Doppler Level

多普勒级别

Determines how much doppler effect will be applied to this audio source (if is set to 0, then no effect is applied).

决定了多少多普勒效应将应用到这个音频信号源(如果设置为0,就是无效果)。

Min Distance

最小距离

Within the MinDistance, the sound will stay at loudest possible. Outside MinDistance it will begin to attenuate. Increase the MinDistance of a sound to make it 'louder' in a 3d world, and decrease it to make it 'quieter' in a 3d world.

在最小距离之内,声音会保持最响亮。在最小距离之外,声音就会开始衰退。增加声音的最小距离,可以使声音在3D世界“更响亮”,减少最小距离可使声音在一个3D世界“安静”;

Max Distance

最大距离

The distance where the sound stops attenuating at. Beyond this point it will stay at the volume it would be at MaxDistance units from the listener and will not attenuate any more.

声音停止衰退距离。超过这一点,它将在距离监听器最大距离单位,保持音量,并不会作任何衰减。

Rolloff Mode

衰减模式

How fast the sound fades. The higher the value, the closer the Listener has to be before hearing the sound.(This is determined by a Graph).

声音淡出的速度有多快。该值越高,越接近监听器最先听到声音(这是由图形决定)

Logarithmic Rolloff

对数衰减

The sound is loud when you are close to the audio source, but when you get away from the object it decreases significantly fast.

当你接近的音频源,声音响亮,但是当你远离对象,声音下降显着快。

Linear Rolloff

线性衰减

The further away from the audio source you go, the less you can hear it.

越是远离音频源的,可以听到的声音越小。

Custom Rolloff

自定义衰减

The sound from the audio source behaves accordingly to how you set the graph of roll offs.

根据你设置的衰减图形,来自音频源的声音行为。

2D Sound Settings

2D 声音设置

Settings that are applied to the audio source if the Audio clip is a 2D Sound.

如果是一个二维的声音,应用到音频源的设置。

Pan 2D

2D平衡调整

Sets how much the engine has an effect on the audio source.

设置多少,引擎在音频源上有效果。

Types of Rolloff

衰减类型

There are three Rolloff modes: Logarithmic, Linear and Custom Rolloff. The Custom Rolloff can be modified by modifying the volume distance curve as described below. If you try to modify the volume distance function when it is set to Logarithmic or Linear, the type will automatically change to Custom Rolloff.

衰减模式有三种:对数,线性和自定义衰减。自定义衰减可以修改通过修改音量的距离曲线,如下所述。当它设置为对数或线性类型时,如果你修改音量距离函数,类型将自动更改为自定义衰减。


Rolloff Modes that an audio source can have.
音频源的衰减模式

Distance Functions

距离函数

There are several properties of the audio that can be modified as a function of the distance between the audio source and the audio listener.

有音频的几个的属性,作为音频源和音频监听器之间的距离的函数,可以被修改。

Volume: Amplitude(0.0 - 1.0) over distance.音量
Pan: Left(-1.0) to Right(1.0) over distance.平衡
Spread: Angle (degrees 0.0 - 360.0) over distance.扩散
Low-Pass (only if LowPassFilter is attached to the AudioSource): Cutoff Frequency (22000.0-10.0) over distance.

低通:(只有当低通滤波器贴到音频源上)低通截止频率()根据距离。


Distance functions for Volume, Pan, Spread and Low-Pass audio filter. The current distance to the Audio Listener is marked in the graph.
音量,平衡调整,扩散和低通音频滤波器的距离函数。当前到音频监听器的距离在途中标记。

To modify the distance functions, you can edit the curves directly. For more information, see the guide to Editing Curves.

要修改的距离函数,您可以直接编辑曲线,想了解更多信息,请参考编辑曲线的指南。

Creating Audio Sources

创建音频源

Audio Sources don't do anything without an assigned Audio Clip. The Clip is the actual sound file that will be played back. The Source is like a controller for starting and stopping playback of that clip, and modifying other audio properties.

没有分配音频剪辑的音频源不会播放任何东西。剪辑是实际的声音文件,该文件将被播放。音频源就像是一个控制器,用于启动和停止播放剪辑,并修改其他的音频属性。

To create a new Audio Source:

创建一个新的音频源

  1. Import your audio files into your Unity Project. These are now Audio Clips.
  2. Go to GameObject->Create Empty from the menubar.
  3. With the new GameObject selected, select Component->Audio->Audio Source.
  4. Assign the Audio Clip property of the Audio Source Component in the Inspector.

1、导入你的音频文件到Unity项目。这些都是现在的音频剪辑。

2、从菜单栏选择GameObject->Create Empty

3、随着新的游戏对象被选择,选择Component->Audio->Audio Source.

4、在检视面板中分配音频源组件的音频剪辑属性

Note: If you want to create an Audio Source just for one Audio Clip that you have in the Assets folder then you can just drag that clip to the scene view - a GameObject with anAudio Source component will be created automatically for it. Dragging a clip onto on existing GameObject will attach the clip along with a new Audio Source if there isn't one already there. If the object does already have an Audio Source then the newly dragged clip will replace the one that the source currently uses.

Platform specific details

 iOS

On mobile platforms compressed audio is encoded as MP3 for speedier decompression. Beware that this compression can remove samples at the end of the clip and potentially break a "perfect-looping" clip. Make sure the clip is right on a specific MP3 sample boundary to avoid sample clipping - tools to perform this task are widely available. For performance reasons audio clips can be played back using the Apple hardware codec. To enable this, check the "Use Hardware" checkbox in the import settings. See the Audio Clip documentation for more details.

 Android

On mobile platforms compressed audio is encoded as MP3 for speedier decompression. Beware that this compression can remove samples at the end of the clip and potentially break a "perfect-looping" clip. Make sure the clip is right on a specific MP3 sample boundary to avoid sample clipping - tools to perform this task are widely available.

Page last updated: 2013-08-06

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值