Version: 5.3 (switch to 5.4b)
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.


class in UnityEngine


Hereda de:Behaviour

Sugiere un cambio


Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.


No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.



Cambiar al Manual


A representation of audio sources in 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.

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.

See Also: AudioListener, AudioClip, AudioSource component.


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.
bypassReverbZonesWhen set doesn't route the signal from an AudioSource into the global reverb associated with reverb zones.
clipThe default AudioClip to play.
dopplerLevelSets the Doppler scale for this 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.
ignoreListenerVolumeThis makes the audio source not take into account the volume of the audio listener.
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.
muteUn- / Mutes the AudioSource. Mute sets the volume=0, Un-Mute restore the original volume.
outputAudioMixerGroupThe target group to which the AudioSource should route its signal.
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.
prioritySets the priority of the AudioSource.
reverbZoneMixThe amount by which the signal from the AudioSource will be mixed into the global reverb associated with the Reverb Zones.
rolloffModeSets/Gets how the AudioSource attenuates over distance.
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.
spatializeEnables or disables spatialization.
spreadSets the spread angle (in degrees) of a 3d stereo or multichannel sound in speaker space.
timePlayback position in seconds.
timeSamplesPlayback position in PCM samples.
velocityUpdateModeWhether the Audio Source should be updated in the fixed or dynamic update.
volumeThe volume of the audio source (0.0 to 1.0).

Funciones Públicas

GetCustomCurveGet the current custom curve for the given 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.
PlayOnDualShock4Enable playing of audio source though a specfic DualShock4 controllerEnable playing of audio source though a specfic DualShock4 controller.
PlayOneShotPlays an AudioClip, and scales the AudioSource volume by volumeScale.
PlayScheduledPlays the clip at a specific time on the absolute time-line that AudioSettings.dspTime reads from.
SetCustomCurveSet the custom curve for the given 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.

Funciones Estáticas

PlayClipAtPointPlays an AudioClip at a given position in world space.

Miembros heredados


enabledEnabled Behaviours are Updated, disabled Behaviours are not.
isActiveAndEnabledHas the Behaviour had enabled called.
gameObjectThe game object this component is attached to. A component is always attached to a game object.
tagEl tag de este game object.
transformThe Transform attached to this GameObject (null if there is none attached).
hideFlagsShould the object be hidden, saved with the scene or modifiable by the user?
nameEl nombre del objeto.

Funciones Públicas

BroadcastMessageLlama al método denominado methodName de todos los MonoBehaviour en este game objecto en cualquiera de sus hijos.
CompareTag¿Este game object está etiquetado con tag?
GetComponentDevuelve un componente de tipo type si el game object tiene a alguno adjuntado, o null si no lo tiene.
GetComponentInChildrenReturns the component of Type type in the GameObject or any of its children using depth first search.
GetComponentInParentReturns the component of Type type in the GameObject or any of its parents.
GetComponentsReturns all components of Type type in the GameObject.
GetComponentsInChildrenReturns all components of Type type in the GameObject or any of its children.
GetComponentsInParentReturns all components of Type type in the GameObject or any of its parents.
SendMessageLlama al método denominado methodName en cada MonoBehaviour de este game object.
SendMessageUpwardsLlama al método denominado methodName en todos los MonoBehaviour de este juego y en todos los ancestros del behaviour.
GetInstanceIDReturns the instance id of the object.
ToStringDevuelve el nombre del objeto.

Funciones Estáticas

DestroyElimina un gameobject, componente o asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadMakes the object target not be destroyed automatically when loading a new scene.
FindObjectOfTypeDevuelve el primer objeto activo cargado de tipo type.
FindObjectsOfTypeDevuelve una lista de todos los objetos activos cargados de tipo type.
InstantiateDevuelve el nombre del objeto.


bool¿Existe el objeto?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.