Mixer GetOrDefault()

robot_2Generated
code_blocksInput

Description

The GetOrDefault method of the MixerHandle struct in the Sandbox.Audio namespace is used to retrieve the associated Mixer object. If the Mixer is not available, it returns a default Mixer instance.

Usage

Use the GetOrDefault method when you need to safely retrieve a Mixer object from a MixerHandle without risking a null reference. This method ensures that you always receive a valid Mixer object, either the one associated with the handle or a default instance.

Example

// Assuming you have a MixerHandle instance
MixerHandle mixerHandle = new MixerHandle();

// Retrieve the Mixer or get a default one
Mixer mixer = mixerHandle.GetOrDefault();

// Use the mixer object
mixer.SetVolume(0.5f);