Mscr: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
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 the playback offset (How far through the sound the channel is while playing) is saved 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.