Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
AudioSource 音频源
# AudioSource 音频源 Inherits from [Behaviour](../Behaviour/Behaviour.html) A representation of audio sources in 3D. 表示在 3D 空间中的音频源。 An AudioSource is attached to a [GameObject](../GameObject/GameObject.html) 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](../AudioListener/AudioListener.html). 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](../GameObject/GameObject.html) 用于在 3D 环境中播放声音。单声道声音以 3D 播放。为了播放 3D 声音,也需要有一个 [AudioListener](../AudioListener/AudioListener.html)。音频监听器通常附加在使用的相机上。立体声总是不以距离为基础衰减。 You can play a single audio clip using [Play](AudioSource.Play.html), [Pause](AudioSource.Pause.html) and [Stop](AudioSource.Stop.html). You can also adjust its volume while playing using [volume](file:///E:/Program%20Files/Unity/Editor/Data/Documentation/Documentation/ScriptReference/AudioSource-volume.html) property, or seek using [time](file:///E:/Program%20Files/Unity/Editor/Data/Documentation/Documentation/ScriptReference/AudioSource-time.html). Multiple sounds can be played on one AudioSource using [PlayOneShot](AudioSource.PlayOneShot.html). You can play a clip at a static position in 3D space using [PlayClipAtPoint](AudioSource.PlayClipAtPoint.html). 你可以使用 [Play](AudioSource.Play.html),[Pause](AudioSource.Pause.html),[Stop](AudioSource.Stop.html) 来播放音频剪辑。也可以在播放时使用 [volume](file:///E:/Program%20Files/Unity/Editor/Data/Documentation/Documentation/ScriptReference/AudioSource-volume.html) 属性调整音量,或者使用 [time](file:///E:/Program%20Files/Unity/Editor/Data/Documentation/Documentation/ScriptReference/AudioSource-time.html) 来定位。多个声音可以使用 [PlayOneShot](AudioSource.PlayOneShot.html) 在一个 AudioSource 上播放。可以使用 [PlayClipAtPoint](AudioSource.PlayClipAtPoint.html) 在 3D 空间中的一个静态位置播放剪辑。 参见:[AudioListener](../AudioListener/AudioListener.html), [AudioClip](../AudioClip/AudioClip.html) ### Variables**变量** * [volume](AudioSource.volume.html) The volume of the audio source. 音频源的音量。 * [pitch](AudioSource.pitch.html) The pitch of the audio source. 音频源的音调。 * [time](AudioSource.time.html) Playback position in seconds. 以秒为单位的播放位置。 * [timeSamples](AudioSource.timeSamples.html) Playback position in PCM samples. 在 PCM 取样的播放位置。 * [clip](AudioSource.clip.html) The default AudioClip to play 默认播放的音频剪辑。 * [isPlaying](AudioSource.isPlaying.html) Is the clip playing right now (Read Only)? 剪辑现在正在播放(只读)? * [loop](AudioSource.loop.html) Is the audio clip looping? 音频剪辑循环播放? * [ignoreListenerVolume](AudioSource.ignoreListenerVolume.html) This makes the audio source not take into account the volume of the audio listener. 这使音频源不考虑音频监听器的音量。 * [playOnAwake](AudioSource.playOnAwake.html) If set to true, the audio source will automatically start playing on awake 如果设置为 true,音频源将在 Awake 时自动播放。 * [velocityUpdateMode](AudioSource.velocityUpdateMode.html) Whether the Audio Source should be updated in the fixed or dynamic update. AudioSource 是否应该以固定或动态的方式更新? * [panLevel](AudioSource.panLevel.html) Sets how much the 3d engine has an effect on the channel. 设置多少,3D 引擎在通道上有效果。 * [bypassEffects](AudioSource.bypassEffects.html) Bypass effects (Applied from filter components or global listener filters) 直通效果(从过滤器组件或全局监听过滤器应用)。 * [dopplerLevel](AudioSource.dopplerLevel.html) Sets the Doppler scale for this AudioSource 设置这个 AudioSource 的多普勒缩放。 * [spread](AudioSource.spread.html) Sets the spread angle a 3d stereo or multichannel sound in speaker space. 设置 3d stereo 的扩散角或扬声器空间的多声道声音。 * [priority](AudioSource.priority.html) Sets the priority of the AudioSource 设置 AudioSource 的优先权。 * [mute](AudioSource.mute.html) Un- / Mutes the AudioSource. Mute sets the volume=0, Un-Mute restore the original volume. 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 * [minDistance](AudioSource.minDistance.html) Within the Min distance the AudioSource will cease to grow louder in volume. 在最小距离内,AudioSource 将停止增大音量。 * [maxDistance](AudioSource.maxDistance.html) (Logarithmic rolloff) MaxDistance is the distance a sound stops attenuating at. (对数衰减)最大距离是一个声音停止衰减的距离。 * [pan](AudioSource.pan.html) Sets a channels pan position linearly. Only works for 2D clips. 设置一个通道平衡调整线性位置,只工作于 2D 剪辑。 * [rolloffMode](AudioSource.rolloffMode.html) Sets/Gets how the AudioSource attenuates over distance 设置/获取 AudioSource 随着距离衰减。 ### Functions**函数** * [Play](AudioSource.Play.html) Plays the clip. 播放剪辑。 * [Stop](AudioSource.Stop.html) Stops playing the clip. 停止播放该剪辑。 * [Pause](AudioSource.Pause.html) Pauses playing the clip. 暂停播放该剪辑。 * [PlayOneShot](AudioSource.PlayOneShot.html) Plays an AudioClip. 播放一个音频剪辑。 * [GetOutputData](AudioSource.GetOutputData.html) Returns a block of the currently playing source's output data 返回一个当前播放源的输出数据块。 * [GetSpectrumData](AudioSource.GetSpectrumData.html) Returns a block of the currently playing source's spectrum data 返回当前播放源的声谱数据块。 ### Class Functions**类函数** * [PlayClipAtPoint](AudioSource.PlayClipAtPoint.html) Plays the clip at position. Automatically cleans up the audio source after it has finished playing. 在指定位置播放剪辑。播放完成后自动消除音频源。 ## Inherited members**继承成员** ### Inherited Variables**继承变量** * [enabled](../Behaviour/Behaviour.enabled.html) Enabled Behaviours are Updated, disabled Behaviours are not. 启用行为被更新,禁用行为不更新。 * [transform](../Component/Component.transform.html) The [Transform](../Transform/Transform.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Transform](../Transform/Transform.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [rigidbody](../Component/Component.rigidbody.html) The [Rigidbody](../Rigidbod/Rigidbody.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Rigidbody](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [camera](../Component/Component.camera.html) The [Camera](../Camera/Camera.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Camera](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [light](../Component/Component.light.html) The [Light](../Light/Light.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Light](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [animation](../Component/Component.animation.html) The [Animation](../Animation/Animation.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Animation](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [constantForce](../Component/Component.constantForce.html) The [ConstantForce](../ConstantForce/ConstantForce.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [ConstantForce](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [renderer](../Component/Component.renderer.html) The [Renderer](../Renderer/Renderer.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Renderer](../Renderer/Renderer.html)[](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [audio](../Component/Component.audio.html) The [AudioSource](AudioSource.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [AudioSource](AudioSource.html)[](../Renderer/Renderer.html)[](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [guiText](../Component/Component.guiText.html) The [GUIText](../GUIText/GUIText.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [GUIText](../GUIText/GUIText.html)[](AudioSource.html)[](../Renderer/Renderer.html)[](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [networkView](../Component/Component.networkView.html) The [NetworkView](../NetworkView/NetworkView.html) attached to this [GameObject](../GameObject/GameObject.html) (Read Only). (null if there is none attached) [NetworkView](../NetworkView/NetworkView.html)[](../GUIText/GUIText.html)[](AudioSource.html)[](../Renderer/Renderer.html)[](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(只读)(如无附加则为空)。 * [guiTexture](../Component/Component.guiTexture.html) The [GUITexture](../GUITexture/GUITexture.html) attached to this [GameObject](../GameObject/GameObject.html) (Read Only). (null if there is none attached) [GUITexture](../GUITexture/GUITexture.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(只读)(如无附加则为空)。 * [collider](../Component/Component.collider.html) The [Collider](../Collider/Collider.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Collider](../Collider/Collider.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [hingeJoint](../Component/Component.hingeJoint.html) The [HingeJoint](../HingeJoint/HingeJoint.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [HingeJoint](../HingeJoint/HingeJoint.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [particleEmitter](../Component/Component.particleEmitter.html) The [ParticleEmitter](../ParticleEmitter/ParticleEmitter.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [ParticleEmitter](../ParticleEmitter/ParticleEmitter.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [gameObject](../Component/Component.gameObject.html) The game object this component is attached to. A component is always attached to a game object. 组件附加的游戏物体。一个组件总是被附加到一个游戏物体。 * [tag](../Component/Component.tag.html) The tag of this game object. 游戏物体的标签。 * [name](../Object/Object.name.html) The name of the object. //物体的名字 * [hideFlags](../Object/Object.hideFlags.html) Should the object be hidden, saved with the scene or modifiable by the user? 物体是否被隐藏、保存在场景中或被用户修改? ### Inherited Functions**继承函数** * [GetComponent](../Component/Component.GetComponent.html) Returns the component of Type type if the game object has one attached, null if it doesn't. 如果游戏物体有一个附加,则返回 Type 类型的组件,如果没有则为 null。 * [GetComponent.<T>](../Component/Component.GetComponent.ltTgt.html) * [GetComponent](../Component/Component.GetComponent.html) Returns the component with name type if the game object has one attached, null if it doesn't. 如果游戏物体有一个附加,则返回名字类型组件,如果没有则为 null。 * [GetComponentInChildren](../Component/Component.GetComponentInChildren.html) Returns the component of Type type in the [GameObject](../GameObject/GameObject.html) or any of its children using depth first search. 返回 Type 类型组件,在 [GameObject](../GameObject/GameObject.html) 或它的任何子物体使用深度优先搜索,仅返回激活的组件。 * [GetComponentInChildren.<T>](../Component/Component.GetComponentInChildren.ltTgt.html) * [GetComponentsInChildren](../Component/Component.GetComponentsInChildren.html) Returns all components of Type type in the [GameObject](../GameObject/GameObject.html) or any of its children. 在 [GameObject](../GameObject/GameObject.html) 或任何它的子物体,返回全部 Type 类型组件 * [GetComponentsInChildren.<T> ](../Component/Component.GetComponentsInChildren.ltTgt.html) * [GetComponents](../Component/Component.GetComponents.html) Returns all components of Type type in the [GameObject](../GameObject/GameObject.html). 在游戏物体返回全部 Type 类型组件。 * [GetComponents.<T> ](../Component/Component.GetComponents.ltTgt.html) * [CompareTag](../Component/Component.CompareTag.html) Is this game object tagged tag? 游戏物体有被标记标签么? * [SendMessageUpwards](../Component/Component.SendMessageUpwards.html) Calls the method named methodName on every [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) in this game object and on every ancestor of the behaviour 在游戏物体每一个 [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) 和每一个 behaviour 的祖先上调用名为 methodName 的方法。 * [SendMessage](../Component/Component.SendMessage.html) Calls the method named methodName on every [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) in this game object. 在游戏物体每一个 [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) 上调用名为 methodName 的方法。 * [BroadcastMessage](../Component/Component.BroadcastMessage.html) Calls the method named methodName on every [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) in this game object or any of its children. 在游戏物体每一个 [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) 和它的全部子物体上调用名为 methodName 的方法。 * [GetInstanceID](../Object/Object.GetInstanceID.html) Returns the instance id of the object. 返回物体的实例 ID * [ToString](../Object/Object.ToString.html) Returns the name of the game object. 返回游戏物体的名称。 ### Inherited Class Functions**继承类函数** * [operator bool](../Object/Object.operator_bool.html) Does the object exist? 物体是否存在? * [Instantiate](../Object/Object.Instantiate.html) Clones the object original and returns the clone. 克隆原始物体,并返回克隆的物体 * [Instantiate.<T>](../Object/Object.Instantiate.ltTgt.html) * [Destroy](../Object/Object.Destroy.html) Removes a gameobject, component or asset. 删除一个游戏物体、组件或资源 * [DestroyImmediate](../Object/Object.DestroyImmediate.html) Destroys the object obj immediately. It is strongly recommended to use Destroy instead. 立即销毁物体 obj,强烈建议使用 Destroy 代替。 * [FindObjectsOfType](../Object/Object.FindObjectsOfType.html) Returns a list of all active loaded objects of Type type. 返回 Type 类型的所有激活的加载的物体列表 * [FindObjectOfType](../Object/Object.FindObjectOfType.html) Returns the first active loaded object of Type type. 返回 Type 类型第一个激活的加载的物体。 * [operator ==](../Object/Object.operator_eq.html) Compares if two objects refer to the same 比较如果两个物体相同 * [operator !=](../Object/Object.operator_ne.html) Compares if two objects refer to a different object 比较如果两个物体不同 * [DontDestroyOnLoad](../Object/Object.DontDestroyOnLoad.html) Makes the object target not be destroyed automatically when loading a new scene. 加载新场景的时候使目标物体不被自动销毁。
da
2022年5月14日 21:57
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码