Version: 2023.2

AudioMixer.FindMatchingGroups

切换到手册
public AudioMixerGroup[] FindMatchingGroups (string subPath);

参数

subPath Path sub-strings to match with.

返回

AudioMixerGroup[] 混合器中路径与指定搜索路径匹配的组。

描述

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. For example, in the hierarchy below, the group DROPS has the path Master/WATER/DROPS. To return only the group called DROPS, enter DROPS. The substring Master/AMBIENCE returns three groups, AMBIENCE/CROWD, AMBIENCE/ROAD, and AMBIENCE. The substring /R would return both ROAD and RIVER.

using UnityEngine;
using UnityEngine.Audio;

public class FindMatchingMixerGroups : MonoBehaviour { public AudioMixer mixer;

static void PrintGroups(AudioMixerGroup[] groups) { Debug.Log("---- MIXER GROUPS ----"); foreach (var group in groups) { Debug.Log(group); } }

void Start() { // Will find all groups with a path containing the substring "DROPS" // In the example, this is a single group defined by the path Master/WATER/DROPS. var groups = mixer.FindMatchingGroups("DROPS"); PrintGroups(groups);

// Will find all groups with a path containing the substring "Master/AMBIENCE" // In the below example, this matches three groups "Master/AMBIENCE/CROWD", "Master/AMBIENCE/ROAD", and "Master/AMBIENCE". groups = mixer.FindMatchingGroups("Master/AMBIENCE"); PrintGroups(groups); } }