AudioSource 音频源
Inherits from Behaviour
A representation of audio sources in 3D.
表示在3D空间中的音频源。
An AudioSource is attached to a GameObject for playing back sounds in a 3D environment. Mono sounds play back 3D. 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. Stereo sounds are always played back without distance based attenuation.
AudioSource附加到一个GameObject用于在3D环境中播放声音。单声道声音以3D播放。为了播放3D声音,也需要有一个AudioListener。音频监听器通常附加在使用的相机上。立体声总是不以距离为基础衰减。
You can play a single audio clip using Play, Pause and Stop. You can also adjust its volume while playing using 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属性调整音量,或者使用time来定位。多个声音可以使用PlayOneShot在一个AudioSource上播放。可以使用PlayClipAtPoint在3D空间中的一个静态位置播放剪辑。
参见:AudioListener, AudioClip
Variables变量
- volumeThe volume of the audio source.
音频源的音量。 - pitchThe pitch of the audio source.
音频源的音调。 - timePlayback position in seconds.
以秒为单位的播放位置。 - timeSamplesPlayback position in PCM samples.
在PCM取样的播放位置。 - clipThe default AudioClip to play
默认播放的音频剪辑。 - isPlayingIs the clip playing right now (Read Only)?
剪辑现在正在播放(只读)? - loopIs the audio clip looping?
音频剪辑循环播放? - ignoreListenerVolumeThis makes the audio source not take into account the volume of the audio listener.
这使音频源不考虑音频监听器的音量。 - playOnAwakeIf set to true, the audio source will automatically start playing on awake
如果设置为true,音频源将在Awake时自动播放。 - velocityUpdateModeWhether the Audio Source should be updated in the fixed or dynamic update.
AudioSource是否应该以固定或动态的方式更新? - panLevelSets how much the 3d engine has an effect on the channel.
设置多少,3D引擎在通道上有效果。 - bypassEffectsBypass effects (Applied from filter components or global listener filters)
直通效果(从过滤器组件或全局监听过滤器应用)。 - dopplerLevelSets the Doppler scale for this AudioSource
设置这个AudioSource的多普勒缩放。 - spreadSets the spread angle a 3d stereo or multichannel sound in speaker space.
设置3d stereo的扩散角或扬声器空间的多声道声音。 - prioritySets the priority of the AudioSource
设置AudioSource的优先权。 - muteUn- / Mutes the AudioSource. Mute sets the volume=0, Un-Mute restore the original volume.
是否静音音频源。Mute是设置音量为0,取消静音是恢复原来的音量。 - minDistanceWithin the Min distance the AudioSource will cease to grow louder in volume.
在最小距离内,AudioSource将停止增大音量。 - maxDistance(Logarithmic rolloff) MaxDistance is the distance a sound stops attenuating at.
(对数衰减)最大距离是一个声音停止衰减的距离。 - panSets a channels pan position linearly. Only works for 2D clips.
设置一个通道平衡调整线性位置,只工作于2D剪辑。 - rolloffModeSets/Gets how the AudioSource attenuates over distance
设置/获取AudioSource随着距离衰减。
Functions函数
- PlayPlays the clip.
播放剪辑。 - StopStops playing the clip.
停止播放该剪辑。 - PausePauses playing the clip.
暂停播放该剪辑。 - PlayOneShotPlays an AudioClip.
播放一个音频剪辑。 - GetOutputDataReturns a block of the currently playing source's output data
返回一个当前播放源的输出数据块。 - GetSpectrumDataReturns a block of the currently playing source's spectrum data
返回当前播放源的声谱数据块。
Class Functions类函数
- PlayClipAtPointPlays the clip at position. Automatically cleans up the audio source after it has finished playing.
在指定位置播放剪辑。播放完成后自动消除音频源。
Inherited members继承成员Inherited Variables继承变量
- enabledEnabled Behaviours are Updated, disabled Behaviours are not.
启用行为被更新,禁用行为不更新。
- transformThe Transform attached to this GameObject (null if there is none attached).
Transform附加到GameObject(游戏物体)(如无附加则为空)。 - rigidbodyThe Rigidbody attached to this GameObject (null if there is none attached).
Rigidbody附加到GameObject(游戏物体)(如无附加则为空)。 - cameraThe Camera attached to this GameObject (null if there is none attached).
Camera附加到GameObject(游戏物体)(如无附加则为空)。 - lightThe Light attached to this GameObject (null if there is none attached).
Light附加到GameObject(游戏物体)(如无附加则为空)。 - animationThe Animation attached to this GameObject (null if there is none attached).
Animation附加到GameObject(游戏物体)(如无附加则为空)。 - constantForceThe ConstantForce attached to this GameObject (null if there is none attached).
ConstantForce附加到GameObject(游戏物体)(如无附加则为空)。 - rendererThe Renderer attached to this GameObject (null if there is none attached).
Renderer附加到GameObject(游戏物体)(如无附加则为空)。 - audioThe AudioSource attached to this GameObject (null if there is none attached).
AudioSource附加到GameObject(游戏物体)(如无附加则为空)。 - guiTextThe GUIText attached to this GameObject (null if there is none attached).
GUIText附加到GameObject(游戏物体)(如无附加则为空)。 - networkViewThe NetworkView attached to this GameObject (Read Only). (null if there is none attached)
NetworkView附加到GameObject(游戏物体)(只读)(如无附加则为空)。 - guiTextureThe GUITexture attached to this GameObject (Read Only). (null if there is none attached)
GUITexture附加到GameObject(游戏物体)(只读)(如无附加则为空)。 - colliderThe Collider attached to this GameObject (null if there is none attached).
Collider附加到GameObject(游戏物体)(如无附加则为空)。 - hingeJointThe HingeJoint attached to this GameObject (null if there is none attached).
HingeJoint附加到GameObject(游戏物体)(如无附加则为空)。 - particleEmitterThe ParticleEmitter attached to this GameObject (null if there is none attached).
ParticleEmitter附加到GameObject(游戏物体)(如无附加则为空)。 - gameObjectThe game object this component is attached to. A component is always attached to a game object.
组件附加的游戏物体。一个组件总是被附加到一个游戏物体。 - tagThe tag of this game object.
游戏物体的标签。
- nameThe name of the object. //物体的名字
- hideFlagsShould the object be hidden, saved with the scene or modifiable by the user?
物体是否被隐藏、保存在场景中或被用户修改?
Inherited Functions继承函数
- GetComponentReturns the component of Type type if the game object has one attached, null if it doesn't.
如果游戏物体有一个附加,则返回Type类型的组件,如果没有则为null。 - GetComponent.<T>
- GetComponentReturns the component with name type if the game object has one attached, null if it doesn't.
如果游戏物体有一个附加,则返回名字类型组件,如果没有则为null。 - GetComponentInChildrenReturns the component of Type type in the GameObject or any of its children using depth first search.
返回Type类型组件,在GameObject或它的任何子物体使用深度优先搜索,仅返回激活的组件。 - GetComponentInChildren.<T>
- GetComponentsInChildrenReturns all components of Type type in the GameObject or any of its children.
在GameObject或任何它的子物体,返回全部Type类型组件 - GetComponentsInChildren.<T>
- GetComponentsReturns all components of Type type in the GameObject.
在游戏物体返回全部Type类型组件。 - GetComponents.<T>
- CompareTagIs this game object tagged tag?
游戏物体有被标记标签么? - SendMessageUpwardsCalls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour
在游戏物体每一个MonoBehaviour和每一个behaviour的祖先上调用名为methodName的方法。 - SendMessageCalls the method named methodName on every MonoBehaviour in this game object.
在游戏物体每一个MonoBehaviour上调用名为methodName的方法。 - BroadcastMessageCalls the method named methodName on every MonoBehaviour in this game object or any of its children.
在游戏物体每一个MonoBehaviour和它的全部子物体上调用名为methodName的方法。
- GetInstanceIDReturns the instance id of the object.
返回物体的实例ID - ToStringReturns the name of the game object.
返回游戏物体的名称。
Inherited Class Functions继承类函数
- DestroyRemoves a gameobject, component or asset.
删除一个游戏物体、组件或资源 - DestroyImmediateDestroys the object obj immediately. It is strongly recommended to use Destroy instead.
立即销毁物体obj,强烈建议使用Destroy代替。 - DontDestroyOnLoadMakes the object target not be destroyed automatically when loading a new scene.
加载新场景的时候使目标物体不被自动销毁。 - FindObjectOfTypeReturns the first active loaded object of Type type.
返回Type类型第一个激活的加载的物体。 - FindObjectsOfTypeReturns a list of all active loaded objects of Type type.
返回Type类型的所有激活的加载的物体列表 - InstantiateClones the object original and returns the clone.
克隆原始物体,并返回克隆的物体