Game.Settings.AudioSettings
Assembly: Game
Namespace: Game.Settings
Type: class
Base: Setting
Summary:
AudioSettings represents the game's audio-related configuration exposed to the settings UI. It defines master/UI/menu/ingame/radio and several advanced group volumes, toggles radio activation, and controls an audio clip memory budget. The class provides defaults and an Apply() method that pushes the settings into the runtime AudioManager and Radio, and adjusts the AudioSourcePool memory budget.
Fields
-
public const string kName = "Audio"
Constant name/key for this settings group (used by the settings system). -
private AudioManager m_AudioManager
Cached reference to the global AudioManager.instance used when applying settings. Lazily populated in Apply(). -
private Radio m_Radio
Cached reference to AudioManager.instance.radio used to enable/disable radio. Lazily populated in Apply(). -
public const string kMainGroup = "Main"
Constant used to mark the "Main" UI settings group. -
public const string kRadioGroup = "Radio"
Constant used to mark the "Radio" UI settings group. -
public const string kAdvancedGroup = "Advanced"
Constant used to mark the "Advanced" UI settings group.
Properties
-
public float masterVolume { get; set; }
Master volume. Exposed in the "Main" UI section via a slider. UI displays 0–100% (slider attributes: min=0, max=100, step=1, unit="percentage", scalarMultiplier=100) while the stored value is a 0.0–1.0 float (defaults to 1.0). -
public float uiVolume { get; set; }
UI sound volume. Same UI slider behavior as masterVolume. Stored 0.0–1.0. -
public float menuVolume { get; set; }
Menu sound volume. Same UI slider behavior as masterVolume. Stored 0.0–1.0. -
public float ingameVolume { get; set; }
In-game sound volume. Same UI slider behavior as masterVolume. Stored 0.0–1.0. -
public bool radioActive { get; set; }
Whether the in-game radio is active. Exposed in the "Radio" section of the settings UI. -
public float radioVolume { get; set; }
Radio volume. Exposed in the "Radio" section; same percentage slider behavior. Stored 0.0–1.0. -
public float ambienceVolume { get; set; }
Ambience volume. Marked as Advanced and shown in the "Advanced" section with the same percentage slider behavior. Stored 0.0–1.0. -
public float disastersVolume { get; set; }
Disasters sound volume. Advanced; same slider behavior. Stored 0.0–1.0. -
public float worldVolume { get; set; }
World sound volume (environmental/world sounds). Advanced; same slider behavior. Stored 0.0–1.0. -
public float audioGroupsVolume { get; set; }
Volume for grouped audio categories. Advanced; same slider behavior. Stored 0.0–1.0. -
public float serviceBuildingsVolume { get; set; }
Volume for service building sounds. Advanced; same slider behavior. Stored 0.0–1.0. -
public int clipMemoryBudget { get; set; }
Memory budget for audio clips (in megabytes). Advanced slider with min=64, max=512, step=32 (unit="dataMegabytes"). Default 256. Applied to AudioManager.AudioSourcePool.memoryBudget (converted to bytes).
Constructors
public AudioSettings()
Initializes a new AudioSettings instance and calls SetDefaults() to populate default values.
Methods
public override void SetDefaults() : System.Void
Sets sane defaults for all settings:- All volume floats default to 1.0 (100%).
- radioActive defaults to true.
-
clipMemoryBudget defaults to 256 (MB).
-
public override void Apply() : System.Void
Pushes the stored settings into the runtime audio systems: - Ensures m_AudioManager is set to AudioManager.instance if null.
- Ensures m_Radio is set to AudioManager.instance.radio if null.
- If m_AudioManager is available, assigns masterVolume, radioVolume, uiVolume, menuVolume, ingameVolume, ambienceVolume, disastersVolume, worldVolume, audioGroupsVolume, and serviceBuildingsVolume to the corresponding AudioManager fields.
- If m_Radio is available, sets m_Radio.isActive to radioActive.
- Sets AudioManager.AudioSourcePool.memoryBudget to clipMemoryBudget multiplied by 1,048,576 (MB → bytes).
- The method guards against null AudioManager/Radio (no exception if audio subsystem not initialized).
Usage Example
// Create, modify and apply audio settings programmatically.
var settings = new Game.Settings.AudioSettings();
// Set master volume to 80% and disable radio:
settings.masterVolume = 0.8f; // underlying value 0.0 - 1.0
settings.radioActive = false;
settings.clipMemoryBudget = 320; // MB
// Push changes to the live AudioManager / Radio and update clip memory budget:
settings.Apply();