- Home /
Question by
EldridgeMisnomer · Feb 15, 2018 at 09:43 PM ·
c#buildaudiosourcewindowsfindgameobjectswithtag
Code for setting AudioSource.volume for various audio sources works in the Editor but not when built.
I have a UI slider acting as a volume control to adjust the volume of the music in my game. The music comes from various different AudioSources so the slider passes its value to the following function:
public void SetMusicVolume(float v) {
GameObject[] musicSources = GameObject.FindGameObjectsWithTag("MusicSource");
foreach (GameObject musicSource in musicSources) {
AudioSource aS = musicSource.GetComponent<AudioSource>();
aS.volume = v;
}
}
This works as I would expect in the Unity editor but when I create a build (for windows x86) the slider does nothing. There are no errors logged. What am I missing?
Comment
Your answer

Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
dll doesn't work after build 0 Answers
Unity 3d - connect android to pc via usb 0 Answers
Use Unity Scene in Windows Phone app 0 Answers