Unreal 5.1 no longer saving to Game.ini config in custom classes?

Hey all! So for years I’ve been relying on the Game.ini file to save a variable between editor sessions. In my case the class is a custom camera actor with a setup similar to this (not a complete class, mind):

UCLASS(config=Game)
class ASomeCameraActor : public ACameraActor
{
   GENERATED_UCLASS_BODY()

   UPROPERTY(Config, EditAnywhere, BlueprintReadWrite)
   float SomeFloat;

public: 
#if WITH_EDITOR
   virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override 
   {
      Super::PostEditChangeProperty(PropertyChangedEvent);
      // Do some things here if needed
      SaveConfig();
   }
#endif
};

This no longer works in Unreal 5.1. With breakpoints I was able to see that unreal does try to save the property to the proper path and name, but no Game.ini file is ever created or changed. If I manually create the Game.ini file in /Saved/Config/WindowsEditor with the values and reload the project, they are loaded correctly BUT they still do not save to the config file when the property is changed.

As a test, I even changed SaveConfig(); to SaveConfig(CPF_Config, TEXT("Game"), GConfig, true); and still no dice.

Did something change that we weren’t made aware of? I do not see anything like this in 5.1’s change notes. So far I can only think its actually a bug on Epic’s part.

(After some digging in UDN with work account)
Turns out this is indeed a bug with 5.1 due to UE tagging the config as NoSave. This will affect changes made during PIE and the editor itself (but not compiled builds?)

1 Like

Here i did a quick test in a static function

void USaveGameSettings::SetVSync(bool isOn) {
	UGameUserSettings* GameSettings = GetMutableDefault<UGameUserSettings>();
	GameSettings->bUseVSync = isOn;
	GameSettings->SetResolutionScaleValue(2);	
	GameSettings->ApplyResolutionSettings(true);
	GameSettings->ApplyNonResolutionSettings();
	GameSettings->SaveSettings();
}

SaveSettings seems to internally call
Scalability::SaveState(GIsEditor ? GEditorSettingsIni : GGameUserSettingsIni);
SaveConfig(CPF_Config, *GGameUserSettingsIni);

GGameUserSettingsIni is set to a variable depending on if it’s in engine or built

in a packaged build it will save to
yourProjectFolder/Saved/Config/Windows/GameUserSettings.ini (platform may vary depending on deployment)

I was having the same problem in UE 5.2 trying to SaveConfig() with a custom settings class in a project plugin. It worked fine in the editor but not in the packaged game. I found the cause to be from the config file setting NoSave to true in this method: https://github.com/EpicGames/UnrealEngine/blob/bf627e6ed60715a749ae4bf8c57988ddc9b722c4/Engine/Source/Runtime/Core/Private/Misc/ConfigCacheIni.cpp#L1323 . Commenting this line out fixed the issue for me.

It looks like this issue is fixed in 5.3: https://github.com/EpicGames/UnrealEngine/blob/d338203f4175ac780f5eb8156063a4bee282db5b/Engine/Source/Runtime/Core/Private/Misc/ConfigCacheIni.cpp#L1317

1 Like