Can I create or load an AudioMixer via script?

I have created an audio mixer asset by following the video tutorials.

Instead of assigning the mixer through public values I want to know if I could load the audio mixer as a resource at run time? or alternatively create one.

I tried ‘Instantiate(Resources.Load(“MasterMixer”)) as AudioMixer;’.
But I get an error ‘snapshot.IsValid () && (snapshot->GetAudioMixer () == PPtr(this))’.

I’m interested in knowing this too.

Basically I’d like to a level scene to check if it was loaded into the main scene. If yes, then route audio through main mixer, if not then create one on the fly for testing purposes.

I’m also interested in finding out if this is possible.

in MonoBehaviour

AudioMixer mixer = GetComponent().outputAudioMixerGroup.audioMixer;

is this work for you?

We load our AudioMixer via Resources.Load without the instantiate and change the volume via script. Working pretty well at the moment except on iOS. Read this thread for more details:

1 Like

I would love this too (I need to find the AudioMixer for saving and loading sound config). For now, I will probably have to go with Tim’s method…