Adding a custom .ini file

I have a bunch of new parameters I want to store in a user-editable place for weapons. I think .ini would be best and I’ve tested it using game.ini.

I’m trying to add my own, custom .ini file, but I’m confused about where/how to do that in a way that it will be packaged and distributed.

I created a new “defaultweapons.ini” along side the other “default” .ini’s and it does get packaged, but I never see a “weapons.ini” the way I see a “game.ini” in the /saved/config directory.

What is the procedure for adding your own, custom config .ini file so it creates the regular one and packages it?

Thanks!

-Shawn

Is there any reason why you want to create your own ini file?

I think that using a UDeveloperSettings is perfect for what you want to do. Just create a new C++ class deriving from UDeveloperSettings



UCLASS(config = Game, defaultconfig)
class MYGAME_API UWeaponsSettings : public UDeveloperSettings
{
    GENERATED_BODY()

    UPROPERTY(config, EditAnywhere)
    float MySettingA;

    UPROPERTY(config, EditAnywhere)
    FStringAssetReference MySettingB;
};


Then you will be able to find and set your settings in the project settings panel in “Game” category.

The settings will be written automatically to DefaultGame.ini and you can access them in C++ by using:



const UWeaponsSettings* WeaponsSettings = GetDefault<UWeaponsSettings>();
WeaponsSettings->MySettingA;
WeaponsSettings->MySettingB;


Well, we anticipate a ton of weapon parameters, so we want to have them all in a different file rather than gumming up the game.ini. So there isn’t a easy way to add another .ini?

Not really, that is the only way for config files, but it doesn’t need to be inside the Game.ini all together, if you write some arbitrary name that works for different stuff: UCLASS(Config = CustomName), but if your plan is use config as configuration for gameplay you should use another approach rather the config files