AudioSource

Struct AudioSource 

Source
pub struct AudioSource {
Show 25 fields pub BypassEffects: bool, pub DopplerLevel: f32, pub Loop: bool, pub MaxDistance: f32, pub MinDistance: f32, pub Mute: bool, pub Pan2D: f32, pub Priority: i32, pub m_Enabled: u8, pub m_GameObject: PPtr, pub m_Pitch: f32, pub m_PlayOnAwake: bool, pub m_Volume: f32, pub m_audioClip: PPtr, pub panLevelCustomCurve: AnimationCurve, pub rolloffCustomCurve: AnimationCurve, pub rolloffMode: i32, pub spreadCustomCurve: AnimationCurve, pub BypassListenerEffects: Option<bool>, pub BypassReverbZones: Option<bool>, pub OutputAudioMixerGroup: Option<PPtr>, pub Spatialize: Option<bool>, pub SpatializePostEffects: Option<bool>, pub m_ExtensionPropertyValues: Option<Vec<ExtensionPropertyValue>>, pub reverbZoneMixCustomCurve: Option<AnimationCurve>,
}
Expand description

AudioSource is a class of the Unity engine since version 3.4.0. Exert from Unity’s scripting documentation: 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.

Fields§

§BypassEffects: bool

Bypass effects (Applied from filter components or global listener filters).

§DopplerLevel: f32

Sets the Doppler scale for this AudioSource.

§Loop: bool

Is the audio clip looping?

§MaxDistance: f32

(Logarithmic rolloff) MaxDistance is the distance a sound stops attenuating at.

§MinDistance: f32

Within the Min distance the AudioSource will cease to grow louder in volume.

§Mute: bool

Un- / Mutes the AudioSource. Mute sets the volume=0, Un-Mute restore the original volume.

§Pan2D: f32§Priority: i32

Sets the priority of the AudioSource.

§m_Enabled: u8

Enabled Behaviours are Updated, disabled Behaviours are not.

§m_GameObject: PPtr

The game object this component is attached to. A component is always attached to a game object. PPtr<GameObject>: (3.4.0 - 2022.3.2f1)

§m_Pitch: f32

The pitch of the audio source.

§m_PlayOnAwake: bool

If set to true, the audio source will automatically start playing on awake.

§m_Volume: f32

The volume of the audio source (0.0 to 1.0).

§m_audioClip: PPtr

PPtr<AudioClip>: (3.4.0 - 2022.3.2f1)

§panLevelCustomCurve: AnimationCurve§rolloffCustomCurve: AnimationCurve§rolloffMode: i32

Sets/Gets how the AudioSource attenuates over distance.

§spreadCustomCurve: AnimationCurve§BypassListenerEffects: Option<bool>

When 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. bool: (4.2.0 - 2022.3.2f1)

§BypassReverbZones: Option<bool>

When set doesn’t route the signal from an AudioSource into the global reverb associated with reverb zones. bool: (4.2.0 - 2022.3.2f1)

§OutputAudioMixerGroup: Option<PPtr>

The target group to which the AudioSource should route its signal. PPtr<AudioMixerGroup>: (5.0.0f4 - 2022.3.2f1)

§Spatialize: Option<bool>

Enables or disables spatialization. bool: (5.2.0f2 - 2022.3.2f1)

§SpatializePostEffects: Option<bool>

Determines if the spatializer effect is inserted before or after the effect filters. bool: (5.5.0f3 - 2022.3.2f1)

§m_ExtensionPropertyValues: Option<Vec<ExtensionPropertyValue>>

Vec: (2017.2.0b2 - 2017.2.0b11)

§reverbZoneMixCustomCurve: Option<AnimationCurve>

AnimationCurve: (5.0.0f4 - 2022.3.2f1)

Trait Implementations§

Source§

impl Debug for AudioSource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AudioSource

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AudioSource

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,