How to store variables to a custom .ini file?
Hey guys I've been using UE4 C++ for the past 6 months and I still don't know exactly how to do this. I am trying to create config variables for user gameplay preferences and graphics settings that would be stored on a custom .ini file. This is what I have now,
This complies with no problems and it generates an .ini file called UserSettings, but the file is blank. Am I on the right track? Can someone maybe show me how to do this correctly?
asked Aug 29 '15 at 06:16 AM in C++ Programming
This is an old question but I was having the same problem and happened across the solution, so I figured I'd post it for posterity. Here's how it works:
Your c++ class definition should look like this.
Edit: Oh and I almost forgot, you can have other properties in your UPROPERTY declaration.
As you noted the UCLASS declaration will automatically create an empty .ini file for you at compile time. Open up that file and type this inside it:
Note how I typed Example in the config file and not AExample. Now whatever values you assigned in the ini file will automatically be loaded into your c++ variables. However, if you want to make a change to the ini file you'll have to completely close out and reload the editor. I haven't yet found a way to reload values on the fly and I'm not sure there is one. You can find more info in the documentation here: https://docs.unrealengine.com/latest/INT/Programming/Basics/ConfigurationFiles/index.html
If the file was created, that's a very good sign.
Have you tried adding your settings to see whether it makes a difference?
At least for Blueprint classes, the syntax is
... where CONTENTPATH is the path within the Content directory.
In the below example, I've added a configurabe variable to the class TestActor, which lies in PROJECTPATH/Content/TopDownBP/Blueprints:
If that doesn't work, try leaving off the "_C" syntax. I think that might be Blueprint-only.
answered Aug 29 '15 at 07:05 AM
Did you see this: https://wiki.unrealengine.com/Config_Files,_Read_%26_Write_to_Config_Files ? Especially the safe path: YourGame\Saved\Config\Windows .
answered Aug 29 '15 at 01:56 PM
Hi guys, I have a question about this:
consider that I have my project cooked with some default settings, but on a specific machine I want to change them. How can I override the values in .ini that has been packaged?
answered Jun 08 '16 at 02:26 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here