- Home /
Muting music at the start of the game.
Hi, I'm trying to locally save sound preferences for my game. The problem I'm currently facing is when I load the preferences and mute the music (using audio mixers), I afterwards start playing the music and you can sometimes hear half a second of the music trying to play before it actually is muted. The only solution i can come up with is to delay the start of the music but that seems a bit like cheating. Is there any other workaround for this? Why does this happen?
I use a coroutine to begin playing the music, and use "yield return null" to skip a frame it seems to work better than using PlayDelayed(random time). But it does seem that the mixers take a frame to update, so you cannot expect to change a mixer and have the change reflect until the next frame.
Answer by $$anonymous$$ · Sep 23, 2015 at 08:43 AM
Did you try to start your Coroutine from
void Start() {
}
?
Have you tried
void Awake(){
}
instead? You can also try to edit your Script Execution Order to load this script first. I'm not really sure if you can skip that extra frame like this though.
Actually working with mixers is a bit weird, I did try to modify the mixer inside an Awake function but it doesn't seem to work, I would guess the mixers aren't ready at that point. I use my coroutine in the Start function yes.
Your answer
Follow this Question
Related Questions
Audiosource.Play() not working 0 Answers
mute/un-mute 1 Answer
Stereo Mix as Input? 1 Answer
Can not play a disabled audio source 2 Answers
Can I play multiple positioned audiosources with one game object? 1 Answer