How to permanently save the GameUserSettings (like resolution) in packaged game?

So in UE4.8.3 I am using the following C++ functions to change some screen settings, like resolution and fullscreen/windowed mode:

Settings->RequestResolutionChange(Width, Height, WindowMode, false);

This works for the running game, i.e. after calling these functions the screen is correctly set to the desired resolution etc. However, none of these settings are being written to a config (ini) file. In fact, there is no such ini file at all in the packaged game.

I found the ini file to be saved in the following folder: %LOCALAPPDATA%/<APP-NAME>/Saved/Config/WindowsNoEditor/GameUserSettings.ini. However, after calling the C++ code shown above, this ini file becomes completely empty, no settings there. So after starting the packaged game again, obviously no settings set the last time are used (as the ini file is empty).

I am totally out of ideas now :frowning:
Could someone please explain to me what I am doing wrong, and what I need to do in order to get this to work?

I’m not sure if this a is a preferred method, but you could probably look into creating save game objects.

I can’t remember the specifics, but it’s as easy as deriving from a certain class, putting all the variables you’d like to save in there and then using a function to save to a game slot.
There are like four relevant functions for loading and saving in UGameplayStatics. I’m sure you’ll find the wiki entry for it or such.
You could then load the settings during startup and apply them.

True, I guess that would be an option.
But I would prefer the “official” way, and I assume using GameUserSettings->SaveSettings() is the official way.

Or have I missed something?

In any case I am quite surprised, isn’t that one of the most essential features nearly any single game must have?!

Hello, i think this wiki page is what you are looking for :,Read%26_Write_to_Config_Files

Thanks, I will have a look.

Hi haimat,

This can be accomplished by saving the settings to .ini files. You can find our documentation on this subject at the following link:

Hope this helps!

That is exactly why I call “Settings->SaveSettings();”, as this is supposed to save the settings to the GameUserSettings.ini file.

I call it like this:


You can see here:

So it turned out that calling RequestResolutionChange() is not enough. That does change the current resolution, but it does not save that internally. Only after calling SetScreenResolution() followed by SaveSettings() those new settings are being saved to the .ini file …

Thanks for all your feedback!

We’re having the same issue too. I don’t quite understand the last comment haimat. You say that you need to call SetScreenResolution() first but in your original post SetScreenResolution is already being called? What we’re seeing is that it is failing to save despite calling SetScreenResolution():

    UGameUserSettings* Settings = GEngine->GameUserSettings;

note: similar to described the resolution is changing during gameplay but is not being set correctly when starting again.

Call ApplySettings().

As it seems we are not the only ones struggling a bit with this.
Thus we wrote a short tutorial on how to permanetly save those game user settings:

Hope it helps!

Very nice haimat, thanks!

You’re welcome, hope it helps!

Thanks for that guide Haimat. It really helped!