Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


FindMatchingGroups(string)

Returns mixer groups whose path contains the specified substring.
Read time 1 minuteLast updated 10 days ago

Definition

public AudioMixerGroup[] FindMatchingGroups(string subPath)

Parameters

subPath

Substring to match against group paths.

Returns

Type

Description

AudioMixerGroup[]Groups in the mixer whose paths contain the specified substring.

Remarks

Connected groups in the mixer form a path from the mixer's master group to the leaves. This path has the format Master Group/Child of Master Group/Grandchild of Master Group, and so on.
AudioMixerFindMatchingGroupsExampleHierarchy (FindMatchingGroups(string))
using UnityEngine;using UnityEngine.Audio;public class FindMatchingMixerGroups : MonoBehaviour{ public AudioMixer mixer; const string dropsVolumeParam = "DropsVolume"; void Start() { // Returns the group at path Master/WATER/DROPS (see hierarchy image above). var dropsGroup = mixer.FindMatchingGroups("DROPS")[0]; // Returns Master/AMBIENCE/CROWD, Master/AMBIENCE/ROAD, and Master/AMBIENCE. var ambienceGroups = mixer.FindMatchingGroups("Master/AMBIENCE"); // Returns ROAD and RIVER. var rGroups = mixer.FindMatchingGroups("/R"); // Exposed parameters are read and written on the AudioMixer, not on AudioMixerGroup. if (dropsGroup.audioMixer.GetFloat(dropsVolumeParam, out float volume)) { Debug.Log($"{dropsVolumeParam}: {volume}"); dropsGroup.audioMixer.SetFloat(dropsVolumeParam, volume); } }}