Download

Function to modify soundClass volume? (Persistent after game restart)

Hi. I’m making and options menu and I got to the sound section and I have a problem.

Is there a function in UDK(US) that lets me modify soundClass volume and saves changes somewhere so when I restart the game the changes will persist or should I implement that functionality myself? And if there is a one how to get the sound volume level for a soundClass so I can plug it in into my interface? I know of two console commands “ModifySoundClass” and “SetAudioGroupVolume” (the second of which is a native function in PlayerController) but both of them don’t save the changes so when you restart the game volume is reset to 100%.

You must use SaveConfig() somewhere in your code to confirm the changes once they are set.

So I guess where the accept settings button functionality will be called is where you’d want to call the SaveConfig() function.

But SaveConfig() only saves changes made to config variables in the class that SaveConfig() is called from, doesn’t it? For exaple if I have ‘var config int MusicVol;’ and I make changes to it somewhere I need to use SaveConfig() to save the changes to cfg file. But SetAudioGroupVolume does not change any config var as far as I know. Or do you mean I must use SaveConfig() if I make my own implementation of saving and loading volume levels from a config file?
Like this:



class SGGame extends UTGame config(Game);

struct Vol
{
	var string Name;
	var float Value;
};
var config array<Vol> SoundVolume;

event PostLogin( playercontroller NewPlayer )
{
	local int i;
	Super.PostLogin(NewPlayer);
	
	for (i = 0; i < SoundVolume.Length; i++)
	{
		NewPlayer.SetAudioGroupVolume(name(SoundVolume*.Name), (SoundVolume*.Value / 100));
	}
}


And then when i change the array vars from my OptionsMenu class I should call SGGame(class’WorldInfo’.static.GetWorldInfo().Game).SaveConfig();

This way of doing it works but I was just wondering is there a way to do this without implementing something like this.