Best place to "load" AudioVolumeSettings?

Hey there,

I’m currently working on a Settings Menu for the Main Menu and In-Game Menu.

For the AudioVolume, I created 3 SoundClasses, 1 Parent Class and 2 Children.
When setting the AudioSettings in my Settings Menu, I use the UGameUserSettings Class,
of which I have a Child with an overridden ApplySettings(…) function.

It iterates through the AudioDevice SoundClasses and applies the Values based on their names:

void UBMGameUserSettings::ApplyAudioSettings()
{
	if (GEngine)
	{
		FAudioDevice* ADevice = GEngine->GetMainAudioDevice();

		if (ADevice)
		{
			for (auto Itr = ADevice->SoundClasses.CreateIterator(); Itr; ++Itr)
			{
				USoundClass* SoundClass = Itr.Key();

				FString SoundClassName;

				if (SoundClass->GetFullName().Split(L".", nullptr, &SoundClassName, ESearchCase::CaseSensitive))
				{
					// Set one of the twoClasses
				    if (SoundClassName == "BMSoundClass_Music")
					{
						SoundClass->Properties.Volume = MusicSoundVolume;
					}
					else if (SoundClassName == "BMSoundClass_SFX")
					{
						SoundClass->Properties.Volume = SFXSoundVolume;
					}
					else
					{
						SoundClass->Properties.Volume = GlobalSoundVolume;
					}
				}
			}
		}
	}
}

This is all working fine. The Float Numbers are saved in the GameUserSettings.ini and are correctly loaded back into the Menu when reopening it. But now I face the problem of actually applying the Settings on Startup.
Because right now, I need to press “ApplySettings” again to apply the SoundVolume again. While the Numbers are saved and loaded, the “Applying” is missing.

It tried calling the ApplyAudioSettings function on LoadSettings of the GameUserSettings class, but that seems to happen WAY too early, so the SoundClasses aren’t yet spawned.

This setting needs to be applied to all SoundClasses. The ones of the MainMenu and every following Level.

What’s the best place to call that, so it’s called at the correct time, every time a new Level is opened?

If you need more information, just tell me. Thanks in advance!

Cheers!

4 days have passed, so I bump this question (: Still haven’t found a good place to load SoundClass Settings!

You should inherit from UGameUserSettings. There you can place additional properties like MasterSoundVolume and store them.

Also look at this question: How to store variables to a custom .ini file? - Editor Scripting - Epic Developer Community Forums