![]() news about forums links tools tutorials contact |
| Using Config Files - author: crack_addict | |
Using Config Files Quite a boring little class with just a couple variables,
nothing special. Now say we want to make the contents of MyString accessible to a config file, we will need to
change to the following: Just by adding the config keyword we have told Unreal that
(a) this class has data to be stored in a config file, and that
(b) we want the MyString variable specifically to be stored/loaded.
Note that only MyString will be stored in the preceding declaration,
you must place the config keyword in front of every variable you want
stored. Now all that's left is to make an entry in the config file
(UnrealTournament.ini will be the default) and add a value for MyString.
And that is all there is to it - Unreal will automatically
load this value and set it properly for every instance of MyClass that we
make. Now say we want to save our data from within the code, we would
implement a function similar to this: Now whenever the SaveMyString() function is called MyString
is set to the new string and then saved to the config file, to be loaded
for future use. You can also change what file the data is saved in by
modifying your class declaration to something like this: This will cause your class to store all of it's config data
in Test.ini now, and you can specify whatever file name you want. There is
also the ResetConfig() function, which will reset the config variables in
your class to the values stored in the config file, sort of a load
function. | |