- Home /
How to change pitch or volume on ALL audio sources in scene?
Hi there!
I'm creating game with slow motion. Maybe someone know how to change pitch on all audio sources in the scene?
Thanks in advance for help.
Answer by KrisCadle · Feb 23, 2012 at 06:55 PM
This will change the pitch of any audio clip on the object with 1 variable. Drag a bunch of clips onto an object, put this script on the same object and you can change all their pitches at the same time by changing myPitch...
var myPitch : float;
function Update () { var sounds : AudioSource[] = FindObjectsOfType(AudioSource) as AudioSource[]; for (var pitch : AudioSource in sounds) { audio.pitch=myPitch; } }
Answer by dannyskim · Feb 23, 2012 at 05:48 PM
Audio sources are like any other object in programming. With that said, there usually is no method or function that will specifically do something like this for you, you have to create it. You'll most likely have to store all the Audio Sources in an array and iterate through it.
Answer by Berenger · Feb 23, 2012 at 05:50 PM
The audiolistener can control the volume general, but for the pitch you'll need to find all audiosources and change their pitch. FindObjectsOfType etc.
Answer by areTeam · Mar 03, 2018 at 01:10 PM
the c# version`enter code public float musicspeed; void Update() for (int i = 0; i < PlayerSkin.Length; i++) { PlayerSkin[i].enabled = true; }here`
P.S. i'm first try the code sample tool