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.

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;
        }
    }

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.

The audiolistener can control the volume general, but for the pitch you’ll need to find all audiosources and change their pitch. FindObjectsOfType etc.

the c# versionenter code public float musicspeed; void Update() for (int i = 0; i < PlayerSkin.Length; i++) { PlayerSkin*.enabled = true;* *}here*
P.S.
i’m first try the code sample tool