Class: AudioComponent
Entity-attached audio source. AudioSystem wires _audio on add; Play()/Stop()/etc. delegate to it. Single-source semantic (Play stops the previous instance). For overlapping playback, use PlayOneShot.
Extends
Constructors
Constructor
ts
new AudioComponent(
assetId?,
volume?,
loop?,
playOnAwake?,
pitch?,
muted?
): AudioComponent;Parameters
| Parameter | Type | Default value |
|---|---|---|
assetId | string | AudioClip | '' |
volume | number | 1 |
loop | boolean | false |
playOnAwake | boolean | false |
pitch | number | 1 |
muted | boolean | false |
Returns
AudioComponent
Overrides
Properties
| Property | Modifier | Type | Default value | Inherited from |
|---|---|---|---|---|
assetId | public | string | undefined | - |
dirty | public | boolean | true | Component.dirty |
enabled | public | boolean | true | Component.enabled |
loop | public | boolean | undefined | - |
muted | public | boolean | undefined | - |
pitch | public | number | undefined | - |
playOnAwake | public | boolean | undefined | - |
volume | public | number | undefined | - |
Accessors
audioClip
Get Signature
ts
get audioClip(): AudioClip;Returns
Set Signature
ts
set audioClip(c): void;Parameters
| Parameter | Type |
|---|---|
c | AudioClip |
Returns
void
Methods
ApplyVolume()
ts
ApplyVolume(): void;Push volume/muted to the live instance without restarting. Call after mutating either.
Returns
void
IsPlaying()
ts
IsPlaying(): boolean;Returns
boolean
Pause()
ts
Pause(): void;Returns
void
Play()
ts
Play(): void;Returns
void
PlayOneShot()
ts
PlayOneShot(assetId, volumeScale?): number;Fire-and-forget overlapping instance. Doesn't touch this.assetId.
Parameters
| Parameter | Type | Default value |
|---|---|---|
assetId | string | undefined |
volumeScale | number | 1 |
Returns
number
Resume()
ts
Resume(): void;Returns
void
Stop()
ts
Stop(): void;One-shots continue to natural end.
Returns
void