Class AudioMixerDependencyCache
Static cache for AudioMixer and AudioMixerGroup assets that keeps Addressables handles alive to prevent Unity from unloading these critical dependencies during the application lifecycle. This solves the issue where AudioMixerGroup references inside ScriptableObjects become "fake-null" when Addressables handles are released.
Inherited Members
Namespace: Serenity.Global.Infrastructure.Utils
Assembly: Serenity.UnityGlobal.Infrastructure.dll
Syntax
public static class AudioMixerDependencyCache
Properties
GroupCount
Gets the count of cached AudioMixerGroups.
Declaration
public static int GroupCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
IsInitialized
Checks if the cache has been initialized.
Declaration
public static bool IsInitialized { get; }
Property Value
| Type | Description |
|---|---|
| bool |
MixerCount
Gets the count of cached AudioMixers.
Declaration
public static int MixerCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
GetDefaultMixer()
Gets the first/default cached AudioMixer (usually there's only one).
Declaration
public static AudioMixer GetDefaultMixer()
Returns
| Type | Description |
|---|---|
| AudioMixer | First cached AudioMixer, or null if none cached |
GetGroup(string, string)
Gets a cached AudioMixerGroup by mixer name and group name.
Declaration
public static AudioMixerGroup GetGroup(string mixerName, string groupName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mixerName | Name of the parent AudioMixer |
| string | groupName | Name of the AudioMixerGroup |
Returns
| Type | Description |
|---|---|
| AudioMixerGroup | Cached AudioMixerGroup, or null if not found |
GetGroupByName(string)
Gets a cached AudioMixerGroup by group name only (searches all cached mixers). This is useful when you know the group name but not the mixer name.
Declaration
public static AudioMixerGroup GetGroupByName(string groupName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | groupName | Name of the AudioMixerGroup |
Returns
| Type | Description |
|---|---|
| AudioMixerGroup | Cached AudioMixerGroup, or null if not found |
GetMixer(string)
Gets a cached AudioMixer by name.
Declaration
public static AudioMixer GetMixer(string mixerName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mixerName | Name of the AudioMixer |
Returns
| Type | Description |
|---|---|
| AudioMixer | Cached AudioMixer, or null if not found |
Initialize(string)
Initializes the cache by loading all AudioMixer assets from Addressables with the given label. The Addressables handles are stored permanently and never released.
Declaration
public static void Initialize(string label = "module:audio-mixer")
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | Addressables label for AudioMixer assets (e.g., "module:audio-mixer") |