Methods
π Summary table
Sound()
Sound
Empty constructor.
Sound(SFX
)
Sound
Constructor that takes an SFX
enum entry.
Sound(string
)
Sound
Constructor that takes a registered tag.
SetVolume(float
)
Sound
Sets the initial volume (0 β 1).
SetHearDistance(float
, float
)
Sound
Sets minimum and maximum hearing distances.
SetVolumeRolloffCurve(VolumeRolloffCurve
)
Sound
Selects a logarithmic or linear roll-off curve.
SetCustomVolumeRolloffCurve(AnimationCurve
)
Sound
Applies a custom roll-off curve.
ChangeVolume(float
, float
)
void
Changes volume during playback (optional lerp).
SetPitch(float
)
Sound
Applies a fixed pitch.
SetRandomPitch()
Sound
Applies a random pitch between 0.85 and 1.15.
SetRandomPitch(Vector2
)
Sound
Random pitch inside a custom range.
SetDopplerLevel(float
)
Sound
Sets Doppler effect intensity.
SetId(string
)
Sound
Assigns a unique ID to the sound.
SetLoop(bool
)
Sound
Enables or disables infinite looping.
SetClip(string
)
Sound
Assigns a clip by tag.
SetClip(SFX
)
Sound
Assigns a clip by SFX
enum.
SetRandomClip(bool
)
Sound
Enables or disables random clip selection.
SetClipByIndex(int
)
Sound
Picks a specific clip by index.
SetPlayProbability(float
)
Sound
Probability (0 β 1) that the sound will play when Play()
is called.
SetPosition(Vector3
)
Sound
Sets the 3-D position of the source.
SetFollowTarget(Transform
)
Sound
Makes the source follow a target.
SetSpatialSound(bool
)
Sound
Toggles 3-D spatial sound.
SetFadeOut(float
)
Sound
Sets fade-out duration.
SetOutput(Output
)
Sound
Sends audio to a specific AudioMixerGroup
.
OnPlay(Action
)
Sound
Callback when playback starts.
OnComplete(Action
)
Sound
Callback when playback ends or is stopped.
OnLoopCycleComplete(Action
)
Sound
Callback at the end of each loop cycle.
OnPause(Action
)
Sound
Callback when the sound is paused.
OnPauseComplete(Action
)
Sound
Callback after the pause fade-out finishes.
OnResume(Action
)
Sound
Callback when the sound resumes.
Play(float
)
void
Plays the sound (optional fade-in).
Pause(float
)
void
Pauses with optional fade-out.
Resume(float
)
void
Resumes with optional fade-in.
Stop(float
)
void
Stops with optional fade-out.
π Detailed description
Sound
Sound()
Sound
Sound()Empty constructor. You must assign a clip or tag before calling Play()
.
Sound
Sound(SFX
sfx)
Sound
Sound(SFX
sfx)Builds the sound using the SFX
enum generated in Audio Creator.
Sound
Sound(string
tag)
Sound
Sound(string
tag)Builds the sound from the tag you registered in Audio Creator.
Sound
SetVolume(float
volume)
Sound
SetVolume(float
volume)Sets the initial volume (0 = silent, 1 = max).
Sound
SetHearDistance(float
minHearDistance, float
maxHearDistance)
Sound
SetHearDistance(float
minHearDistance, float
maxHearDistance)Defines the distance at which the sound is fully audible and the distance at which it starts fading in.
Sound
SetVolumeRolloffCurve(VolumeRolloffCurve
curve)
Sound
SetVolumeRolloffCurve(VolumeRolloffCurve
curve)Selects the Logarithmic or Linear roll-off curve for distance attenuation.
Sound
SetCustomVolumeRolloffCurve(AnimationCurve
customCurve)
Sound
SetCustomVolumeRolloffCurve(AnimationCurve
customCurve)Lets you apply an AnimationCurve
you created for custom attenuation.
void
ChangeVolume(float
newVolume, float
lerpTime)
void
ChangeVolume(float
newVolume, float
lerpTime)Changes the volume while the sound is playing. If lerpTime
> 0 the change is smoothed.
Sound
SetPitch(float
pitch)
Sound
SetPitch(float
pitch)Sets a fixed pitch (also affects playback speed).
Sound
SetRandomPitch()
Sound
SetRandomPitch()Automatically applies a random pitch between 0.85 and 1.15.
Sound
SetRandomPitch(Vector2
pitchRange)
Sound
SetRandomPitch(Vector2
pitchRange)Applies random pitch inside the custom range you pass.
Sound
SetDopplerLevel(float
dopplerLevel)
Sound
SetDopplerLevel(float
dopplerLevel)Defines Doppler intensity (0 β 5).
Sound
SetId(string
id)
Sound
SetId(string
id)Assigns a unique ID so you can control the sound via SoundsGoodManager
without a direct reference.
Sound
SetLoop(bool
loop)
Sound
SetLoop(bool
loop)true
β infinite looping, false
β plays once.
Sound
SetClip(string
tag)
Sound
SetClip(string
tag)Assigns a clip using its tag from Audio Creator.
Sound
SetClip(SFX
sfx)
Sound
SetClip(SFX
sfx)Assigns a clip using the SFX
enum.
Sound
SetRandomClip(bool
random)
Sound
SetRandomClip(bool
random)If enabled, a random clip is chosen each time you call Play()
.
Sound
SetClipByIndex(int
index)
Sound
SetClipByIndex(int
index)Plays a specific clip by its index inside the tagβs clip array.
Sound
SetPlayProbability(float
probability)
Sound
SetPlayProbability(float
probability)Sets the chance (0 β 1) that the sound will actually play when Play()
is invoked.
Sound
SetPosition(Vector3
position)
Sound
SetPosition(Vector3
position)Sets the world position of the audio source.
Sound
SetFollowTarget(Transform
followTarget)
Sound
SetFollowTarget(Transform
followTarget)Makes the audio source follow the given Transform
every frame.
Sound
SetSpatialSound(bool
activate)
Sound
SetSpatialSound(bool
activate)true
β 3-D spatial sound; false
β global (2-D) sound.
Sound
SetFadeOut(float
fadeOutTime)
Sound
SetFadeOut(float
fadeOutTime)Duration of the fade-out when the clip ends or is stopped.
Sound
SetOutput(Output
output)
Sound
SetOutput(Output
output)Routes the sound to a specific channel managed by an Audio Mixer.
Sound
OnPlay(Action
onPlay)
Sound
OnPlay(Action
onPlay)Callback fired when playback starts.
Sound
OnComplete(Action
onComplete)
Sound
OnComplete(Action
onComplete)Callback fired when playback finishes naturally or is stopped manually.
Sound
OnLoopCycleComplete(Action
onLoopCycleComplete)
Sound
OnLoopCycleComplete(Action
onLoopCycleComplete)Executed each time a loop cycle finishes, if loop
is enabled.
Sound
OnPause(Action
onPause)
Sound
OnPause(Action
onPause)Immediate callback when the sound is paused.
Sound
OnPauseComplete(Action
onPauseComplete)
Sound
OnPauseComplete(Action
onPauseComplete)Fires after the pause fade-out completes.
Sound
OnResume(Action
onResume)
Sound
OnResume(Action
onResume)Callback fired when the sound resumes after being paused.
void
Play(float
fadeInTime)
void
Play(float
fadeInTime)Plays the sound. If fadeInTime
> 0, applies a fade-in.
void
Pause(float
fadeOutTime)
void
Pause(float
fadeOutTime)Pauses the sound. If fadeOutTime
> 0, fades out before pausing.
void
Resume(float
fadeInTime)
void
Resume(float
fadeInTime)Resumes playback, applying a fade-in if specified.
void
Stop(float
fadeOutTime)
void
Stop(float
fadeOutTime)Stops the sound. If fadeOutTime
> 0, performs a fade-out; if 0, stops immediately.
Last updated