CVR Audio Driver
Switches between multiple audio clips that share a single AudioSource. Useful when you need many audio clips at the same location with the same settings.
Properties
Section titled “Properties”Audio Source
Section titled “Audio Source”The Audio Source the clips play on. The component assigns the selected clip onto audioSource.clip before playback.
Audio Clips
Section titled “Audio Clips”List of Audio Clips to switch between.
Selected Audio Clip
Section titled “Selected Audio Clip”Index into audioClips for the currently selected clip. Can be driven at runtime by an animation: the component watches for changes in OnValidate and OnDidApplyAnimationProperties and swaps the clip when the value changes.
Play On Switch
Section titled “Play On Switch”If enabled, the new clip plays automatically when the selection changes. Default true.
Scripting API
Section titled “Scripting API”All methods are exposed to Lua scripting under the CVR.CCK module.
| Method | Description |
|---|---|
PlaySound(int index) | Sets selectedAudioClip to index, and if playOnSwitch is true, plays the clip. |
PlaySound() | Plays the currently assigned clip on the AudioSource if it is active and enabled. |
PlayNext() | Advances to the next clip in the list (wraps to 0). |
PlayPrev() | Moves to the previous clip in the list (wraps to the last entry). |
SelectRandomSound() | Picks and plays a random clip from the list. |
SetAudioClip(int index) | Sets the selected clip without playing. Returns false if the index is out of bounds or the clip or source is null. |
Animation Events
Section titled “Animation Events”The component also exposes AnimEventPlaySound, AnimEventPlayNext, AnimEventPlayPrev, and AnimEventSelectRandomSound for use as Unity AnimationEvent targets.
Source
Section titled “Source”CVR-GameFiles/ABI.CCK.Components/CVRAudioDriver.cs