Any good guide for creating/handling Config(.ini) with C++?

I am trying to get in to UE Config field, make my own config files, add/edit stuff in default UE Configs like Engine, Game and so on. Aim to get better understanding of how it all working.

But spent entire day already and achieved nothing but frustration, exhaustion and disappointment. Lack of good, comprehensive examples is real, basically nothing in video format(or youtube search is so crap so I failed to find any related).

The main Epic’s guide is somehow not working, I can’t understand why, I am following it all and seems like understand it but no success, can’t read, not write to my Config files, SaveConfig does nothing as well.

Here is my most simple stuff:

devenv_rI4ttZiyy8

Isn’t SaveConfig should save all in to DefaultMyConfig.ini or create it if it does not exist? Because it clearly does nothing in my case.

I just wrote stuff to myGameConfiig.ini, syntax is really simple. Just use printf and write to file.

Several mistakes in Epic’s guide I found because of it, this documentation does not work. Here is few now:

In that example such stuff with A prefix in class would not compile:

Error: Class ‘AMyConfigActor’ has an invalid Unreal prefix, expecting ‘UMyConfigActor’

Secondly, no public: specifier, so from *settings-> you won’t be able to even acess your variables like MyConfigVariable from documentation.

So the purpose of this thread of mine remains: how much more there is mistakes that not so visible, but still exists, so people not even able to create their simplest, primitive MyConfig.ini?

No mate I don’t think that’s correct way to do this. There is whole config-related functional toolbox created and available by the engine, to write from config, read, save, load, and other stuff to do it right way.

EDIT:
So far the only positive I am getting is reading existing variables from the Default UE configs, like this works fine:

FString str1;
GConfig->GetString(TEXT("/Script/UnrealEd.ProjectPackagingSettings"), TEXT("BuildConfiguration"), str1, GGameIni);
GEngine->AddOnScreenDebugMessage(-1, 7, FColor::Magenta, "ini str val1: " + str1);

Okay, important thing I never saw mentioned - you should never test any of your .ini-related stuff by Playing In Editor(Selected Viewport or New Editor Window(PIE)), it won’t work properly and will fail get current values from your .ini’s. Only run with Standalone Game.

I found my primary source of struggle: SaveConfig() not working anymore for whatever reason for several(!) months(?).

Use TryUpdateDefaultConfigFile(); instead.

1 Like