- Home /
Is it possible to route an AudioSource/Clip to a specific bus in the mixer through script?
I know Unity5 was literally just released today, but i'm wondering if anyone knows if you can take an audioSource or AudioClip and tell Unity to route the sound of that Source/Clip to a specific mix bus.
Ideally what I want to do is take a music file, break it down into layers and then create an array for those layers. I want the system to automagically
assign AudioSource/Clip array[0] -> to Mixer Bus named Music->Layer 1
assign AudioSource/Clip array[1] -> to Mixer Bus named Music->Layer 2
assign AudioSource/Clip array[2] -> to Mixer Bus named Music->Layer 3
...
so on.
Any feedback regarding this issue would be great.
Answer by Selcuk_Bor · Mar 05, 2015 at 05:52 PM
Yes it is.
public AudioSource theAudioSource;
public AudioMixerGroup mixerGroup;
void start(){
theAudioSource.outputAudioMixerGroup = mixerGroup;
}
done deal. So simple, I feel pretty stupid for not realizing it.
Answer by thestrongskye · Jan 27, 2017 at 12:55 AM
How can i set mixer to audio source array ?
public AudioMixerGroup MyMixer;
public AudioSource[] AudioSources;
if (something) {
AudioSources.outputAudioMixerGroup = MyMixer;
}
Error, so how?
You need to iterate through the array and assign the mixer group to each individual element in your array:
for(int i = 0; i < AudioSources.length; i++)
{
AudioSources[I].outputAudio$$anonymous$$ixerGroup = $$anonymous$$y$$anonymous$$ixer;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613185043im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Play Audio on Collision or Trigger Enter 4 Answers
How can we change default playback device in unity? 2 Answers
Audio Question 2 Answers
Unity 3.5 Beta Audio in SWF issue ! 2 Answers
Walking sound Help 2 Answers