subPath | 要匹配的路径子字符串。 |
AudioMixerGroup[] 混合器中路径与指定搜索路径匹配的组。
混合器中的连接组从混合器的母版组到叶子形成一条路径。这条路径的格式为 母版组/母版组的子级/母版组的孙子,依此类推。例如,在下面的层次结构中,DROPS 组的路径为 母版/WATER/DROPS。要仅返回名为 DROPS 的组,请输入 DROPS。子字符串 母版/AMBIENCE 将返回三个组,AMBIENCE/CROWD、AMBIENCE/ROAD 和 AMBIENCE。子字符串 /R 将返回 ROAD 和 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); } }