Jump to content

Mscr:Audio.Channel: Difference between revisions

From Ironworks Games Wiki
Created page with "category:Mscr:Audio {{note|Path| Audio.Channel}} A custom audio channel. These always play as 2D sounds, and are generally used for music, cutscene audio, or anywhere you want an audio track that can be saved and loaded. Audio Channels are also not restricted to the channel limits that AudioSources are, so you can have as many or as few as you want. = Details = <syntaxhighlight lang="cs">..."
 
 
Line 69: Line 69:
|}
|}


This allows you to set whether or not the playback offset (How far through the sound the channel is while playing) is saved to the savegame. Setting this to <code>false</code> will mean that the position within the sound won't be affected, either resetting its position to the start if the scene is loaded from fresh, or leaving it where it was if the scene is reloaded in-place.
This allows you to set whether or not to save the playback offset (How far through the sound the channel is while playing) to the savegame. Setting this to <code>false</code> will mean that the position within the sound won't be affected, either resetting its position to the start if the scene is loaded from fresh, or leaving it where it was if the scene is reloaded in-place.


Playback Offset Serialization defaults to <code>true</code> internally.
Playback Offset Serialization defaults to <code>true</code> internally.

Latest revision as of 02:43, 3 September 2026

A custom audio channel.

These always play as 2D sounds, and are generally used for music, cutscene audio, or anywhere you want an audio track that can be saved and loaded.

Audio Channels are also not restricted to the channel limits that AudioSources are, so you can have as many or as few as you want.

Details

class Audio.Channel : Object
Object Type: class (Copy by Reference)
Inherits From: System.Types.Object

Constructors

Audio.Channel(Audio.Category category)

Arguments:

Type Argument Description
Audio.Category category The Audio Category for this channel.

Public Methods

PlaySound

void PlaySound(Audio.SoundFile soundFile, bool loop = false, float volume = 1.0f, float pitch = 1.0f, float timeOffset = 0.0f)

Arguments:

Type Argument Description
Audio.SoundFile soundFile The sound file to play
bool loop Whether or not this sound should loop if it reaches the end. Defaults to false
float volume The volume to play this sound at. Defaults to false
float pitch The pitch scale offset to play this sound at, as a scalar. Defaults to 1.0f
float timeOffset How far through the sound to start, in seconds. Defaults to 0.0f

Plays a SoundFile on this channel. If a sound was previously playing on this channel, it will be stopped and replaced.

If soundFile is null, will stop the currently playing sound.

Stop

void Stop()

Stops any currently playing sound.

SetPlaybackOffsetSerializationEnabled

void SetPlaybackOffsetSerializationEnabled(bool enabled)

Arguments:

Type Argument Description
bool enabled Whether to enable or disable playback offset serialization

This allows you to set whether or not to save the playback offset (How far through the sound the channel is while playing) to the savegame. Setting this to false will mean that the position within the sound won't be affected, either resetting its position to the start if the scene is loaded from fresh, or leaving it where it was if the scene is reloaded in-place.

Playback Offset Serialization defaults to true internally.