Config not being saved (UPROPERTY, UCLASS)
I'm trying to save some variables into a config file, i followed every solution i found on the web/answerhub but nothing seems to work.
I checked in /Config and /Saved/Config/[Platform]/ no variable is saved, i tried UCLASS(Config=) with uppercase and lowercase (i saw both on example) and of course other config file name. And i tried to delete the /Saved folder and even multiple full project recompilation (by deleting /Saved /Intermediate/ /Binary
Where am i wrong ?
Thanks in advance !
asked May 31 '17 at 12:47 PM in C++ Programming
You shouldn't be assigning values to the config variables within the header file.
You can set default values within the appropriate default config file (in your instance "GAMENAMEGame.ini", wherein "GAMENAME" is the actual name of your game) under a heading for your class holding the config variables:
Replace "GAMEMODULE" with the actual name of your game module.
Then, when you run your game, the values within the config file will be read into the variables in your class.
The values will only appear within the "/Saved/Config/[Platform]/" files if they are different from the default; otherwise the default values will be used.
In order to modify them, you have to use the GConfig global:
GConfig also has SetText, SetInt, SetBool, SetColor, SetVector, and SetRotator to store other types of variables. FName values should be converted to FString when storing.
The section and key arguments can be held in an FString, but will need to be passed in via pointer. Values are passed normally:
After setting the values, you need to flush the config file to ensure they are applied:
Or, from within your UCLASS(Config) object you can call "SaveConfig();"
You can also read from config files into any variable, without using the UCLASS and UPROPERTY specifiers:
Follow this question
Once you sign in you will be able to subscribe for any updates here