Audio Source (Scripting API)
Objects with an Audio Source component can play sounds through scripts.
Basic usage
if (ctx.HasAudioSource()) {
ctx.SetAudioLoop(true);
ctx.SetAudioVolume(0.85f);
ctx.PlayAudio(); // start current clip
ctx.StopAudio(); // stop playback (will not auto-restart)
ctx.SetAudioClip("Assets/Audio/new.ogg"); // swap clip
ctx.PlayAudio(); // start the new clip
}Functions
Notes
Last updated
Was this helpful?
