UGameUserSettings questionwith Scalability Settings

Hello out there,

i am currently working on Scalability Settings so a player can alter various settings via an UI.

It works well using console commands for settings those value -> save them to a config -> load it from there as well.

However when i used the GameUserSettingsIni to store ScalabilityGroup values a noticed that the saved values inside are set back to engine default when you start up the editor again.
After some research i found out why.

Inside the UGameUserSettings class inside the ctor it calls SetToDefaults as you can see below:



UGameUserSettings::UGameUserSettings(const FObjectInitializer& ObjectInitializer)
:	Super(ObjectInitializer)
{
	SetToDefaults();
}


I even learned inside this class that you shouldnt use CVars directly via console commands as stated inside Scalability.h



/** This is the only suggested way to set the current state - don't set CVars directly **/
	ENGINE_API void SetQualityLevels(const FQualityLevels& QualityLevels);

	/** This is the only suggested way to get the current state - don't get CVars directly */
	ENGINE_API FQualityLevels GetQualityLevels();


However, i guess my current system which does all this is working but its not the intended way of doing things.

I guess, i need to subclass UGameUserSettings with my own one. And use this class as default… i also need to prevent to call the base class ctor from calling SetToDefaults

How would i set this class to be the global GameUserSettings instance?
Is this the intended way?
Any other ideas?

kind regards

Set your GameUserSettings subclass in your DefaultEngine.ini:


[/Script/Engine.Engine]
GameUserSettingsClassName=/Script/MyGameModule.MyGameUserSettings

It doesn’t matter that the base constructor is calling set to defaults. This is how UObjects work. Defaults are serialized in, then config properties read their settings from the appropriate .ini file (determined by Config=IniName in the UCLASS declaration) and overwrite the defaults with these values.

Scalability is a bit complicated because they add an extra layer of configuration through the scalabilty group (“sg”) console variables. You can tailor the scalability groups to your liking by editing DefaultScalability.ini for your game project.

Call GEngine->GetGameUserSettings() to get your user settings instance, update the values on them however you like and then call SaveSettings() on the instance. It updates the scalability values and then calls SaveConfig in order to write to the user’s GameUserSettings file.

Hey thanks,

well SetToDefaults() is important, because it will override your custom config GamUserSettings in Saved with the ones from Default. So it is indeed a problem.
But thanks for the hint with the Engine.ini.
I was looking through it and havnt found such an entry, but i guess i can just add it.

As you may know you dont have to call save settings as it will be done when you apply your settings.

The intended way is to use the QualityLevels struct inside GameUserSettings. In that struct you can alter the “sg” vars.
After that you call ApplySettings() -> which will execute the cvars and save it to config.