logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    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.

    Inheritance
    object
    AudioMixerDependencyCache
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    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, selecting the load source from SerenityAssetLoadingModeProvider.

    • ResourcesOnly: synchronously loads via Resources.LoadAll<AudioMixer>(""). Safe on every platform including WebGL because no Addressables API is invoked.
    • AddressablesOnly and AddressablesWithResourcesFallback: synchronously loads via Addressables.LoadAssetsAsync(label).WaitForCompletion(), keeping the handle alive for the lifetime of the application. On WebGL this throws NotSupportedException because WaitForCompletion cannot be serviced — the caller must switch to SerenityAssetLoadingMode.ResourcesOnly or drive cache initialization from an async path. The sync WebGL guard is preserved per the slice contract.

    The guard is intentionally scoped to the Addressables branch: it exists to flag the genuinely unsafe sync call, not to forbid synchronous initialization in ResourcesOnly where no Addressables API is touched at all.

    Declaration
    public static void Initialize(string label = "module:audio-mixer")
    Parameters
    Type Name Description
    string label

    Addressables label for AudioMixer assets (defaults to AUDIO_MIXER). Unused in ResourcesOnly mode.

    In this article
    © 2026 Serenity. All Rights Reserved