How to override DefaultGame.ini after Packaging?

Hello!

I subclassed the GameState and added a couple of string variables exposed in DefaultGame.ini, here it is:

[/Game/MyProject/MyGameStateBP.MyGameStateBP_C]
MyServer=“http://192.168.127.103:3030

After packaging, I would like to change this value with another address, how could I do?

I tried putting another DefaultGame.ini file under all folders in the package, such as Project/Config, or Saved/Config,
but it never changed. What am I missing?

Thanks a lot

Hey

Did you save your DefaultGame.ini file in the correct location? Please check here with our [Configuration Files Documentation][1]!

Thanks!

Configuration Files in Unreal Engine | Unreal Engine 5.1 Documentation

Hey

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you!

Hi ,

I read that document and tried to put that file in several folders, but none worked. What is the correct folder? The easiest one, I dont need localization nor different platform. Just simple windows.

Thanks

Hi ,

I read that document and tried to put that file in several folders, but none worked. What is the correct folder? The easiest one, I dont need localization nor different platform. Just simple windows.

Thanks

If you’re just trying to find the DefaultGame.ini for your project simply try this example: C:\Users\Desktop\MyProject\Config and then inside of the Config folder there will be the DefaultGame.ini.

I tried. But nothing happened. Maybe because I have some “GameState” config variables, I don’t know.
I tried to debug the engine, but the ConfigCacheIni.cpp seems to be outside the scope of the PDB so I cannot break inside to see what is happening under the hood.

What else could I try? Is it possible to override the game.ini from the command line?
Thank you

I think I solved my problem.

I try to explain the solution in case someone else gets trapped in this point.

I created a new class, say MySettings, and stated that I want it to be written on a custom Config file, and added the variables tagged as “Config” .

Then I told my GameState-derived class to instanciate it at BeginPlay (now I’ll try to load it at construction time, but it’s almost the same).

In the config file I wrote:
[/Script/MyProject.MySettingClass]
WebServerURL=pluto

And put this file under "Saved/Config/WindowsNoEditor/MySettingClass.ini
And it works as expected.

I suppose that the part I was missing was that the GameState, as a uasset, is cooked.
Maybe unreal gives precedence to the cooked value rather than my default .ini file.

Implementing it this way, instead, I put it under the domain of /Script/, not /Game/, so there’s no other variable that could override it in cooking.

The configs only use the prepended “Default” in 1 location. That is /Config.

so for DefaultGame.ini that is /Config/DefaultGame.ini. Default is the only file looked for in this folder, and this folder is the only place Default is looked for.

In the engine config is a BaseGame.ini, a Platform split in the configs/platform folder, then we get to the DefaultGame.Ini in the project config folder, and a Project config / platform folder, IE: PS4Game.ini, and finally in your project/saved/config is just Game.ini.

When you cook and package these are all compiled into a single Game.ini which is placed into the .PAK file.

I dont think this works, but you can try. The Saved Folder does not have the “Default” prefix. It would just be Game.ini.

But this should not work. It is a hacking exploit. And I thought that it dropped out of shipping / test builds. If not then this is a bug in unreal.