Version: 2021.3
LanguageEnglish
  • C#

AudioMixerGroup.audioMixer

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public Audio.AudioMixer audioMixer;

Description

Gain access to the AudioMixer that this AudioMixerGroup belongs to (Read Only).

This property is useful if you want to access the AudioMixer and modify its properties or the properties of its groups dynamically.

using UnityEngine;
using UnityEngine.Audio;

public class ExampleAudioMixer : MonoBehaviour { public AudioMixerGroup audioMixerGroup;

void Start() { // Output the name of the AudioMixer that this AudioMixerGroup belongs to AudioMixer parentMixer = audioMixerGroup.audioMixer; Debug.Log("AudioMixer Name: " + parentMixer.name);

// Use the exposed parameters of different AudioMixerGroups to change the volume of those groups. // Make sure to expose the parameters you want to change in your groups and rename them to something memorable. // "TestVolume" and "MainVolume" are the exposed and renamed volume parameters of 2 different AudioMixerGroups. parentMixer.SetFloat("TestVolume", -80f); parentMixer.SetFloat("MainVolume", 5.0f); } }