Hi all!
I use Cocos Creator version 3.8.3.
Is there a way to change the global volume in the engine? So far, what I have found is to change the volume individually for each AudioSource.
Hi all!
I use Cocos Creator version 3.8.3.
Is there a way to change the global volume in the engine? So far, what I have found is to change the volume individually for each AudioSource.
Hi @dubrovkin, I am pretty new to cocos creator myself but thought I would look at the docs on this myself. It looks to me like the idea of a Global AudioEngine.setVolume was retired…
But maybe you could setup a Global Volume manager script… I don’t know, something like this?
import { _decorator, Component, AudioSource, Node } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('GlobalVolumeManager')
export class GlobalVolumeManager extends Component {
@property({ type: [AudioSource] })
audioSources: AudioSource[] = [];
setGlobalVolume(volume: number) {
this.audioSources.forEach(audioSource => {
audioSource.volume = volume;
});
}
}
Then you could set them like this:
const globalVolumeManager = this.node.getComponent(GlobalVolumeManager);
globalVolumeManager.setGlobalVolume(0.5);
Hope that is of use in some way, good luck.