Save & Loading settings inside graphics widget

Hello everyone I’m having a strange situation going on inside my WB_Graphics widget all my game settings are there like Vsync and resolution, but then three options that I recently worked on they save in the settings but they only load when I open the in game graphics menu I don’t know how to get around this maybe the setup is wrong, so a little help would be appreciated, in the videos it shows how I

save and load those settings

What I can gather from a quick glance is that all settings except the last 3 are saved in Game User Settings. This is a persistent object (I think saved in UserSettings.ini) and crucially, loaded on game start. The last 3 are saved in a save file which needs to be loaded manually and is pobably loaded manually when the widget opens, hence the described behavior.

If my suspicion is correct you can skip calling OnStartLoadSavedSettings and I bet the sttings saved in Game User Settings will still be applied.

What you should do is take OnStartLoadSavedSettings functionality out of the widget and place it in your GameInstance. (skip loading all the Game user settings too)

For more details you can check this post.

Wait not fully understanding this, but if I remove the OnStartLoadSavedSettings function from the widget and into the game instance wont i have to recreate all those variables that were inside it into the game instance?

The issue you are having (that the settings in your save file only load when you open the in game graphics menu) is because the function that loads them (OnStartLoadSavedSettings) is called somewhere (probably on BeginPlay) in your widget (WB_Graphics) which only exists after you construct it/open it.

Moving OnStartLoadSavedSettings in a custom GameInstance will allow you to call it on EventInit which is called at the start of your game. Moreover this object persists between levels and mods so it is always accessible.

All the variables from GameUserSettings are loaded and applied automatically so you wont need them in OnStartLoadSavedSettings. However, you’ll still need get them so you can set the right values of your controls in your widget.

I understand what you’re saying but it’s getting into is my problem, easier said than done based on how my project is set up :sweat_smile:

So in these two screenshots is this how it should be in the game instance? and also you said i’ll still need the variables from my graphics widget would referncing be my best option?

Nope, sorry. You got only a small portion of what I said.

  1. Divide your OnClicked(ApplySettings) and OnStartLoadSavesSettings in two parts:
    • One containing the initial 7 or so settings that are stored in GameUserSettings. Lets call them GameUserSettingsApply() and GameUserSettingsGet()
    • A second one containing the last 3 settings stored in the SaveFile. Lets call them them SaveFileApply() and SaveFileGet()
  2. In your MyGameInstance.EventInit() you only place yourSaveFileGetand store the values in the MyGameInstance itself.
  3. In your widget you:
    • First call GameUserSettingsGet then get the values from the GameInstance. This is done in order to show the current settings in the menu - nothing more.
  4. On apply you call both GameUserSettingsApply() and SaveFileApply().

If you want it to be better - move all loading and saving functionality in the GameInstance and just call MyGameInstance.Get() when you open the menu and MyGameInstance.Apply()when you click the button.