I’m writing a plugin and I’m trying to figure out how configuration .ini files and the Config=
class propery work from Configuration Files | Unreal Engine 4.27 Documentation and there’s a lot of things that are confusing me
If I have a plugin Foobar
, and I have a class called
UCLASS(Config=Foobar)
class UFoobarSettings
{
UPROPERTY(Config)
int Prop1;
UPROPERTY(Config)
int Prop2;
...
}
…and then I create a file in
MyGame/Plugins/Foobar/Config/DefaultFoobar.ini
with
[/Script/Foobar.FoobarSettings]
Prop1=111
Prop2=222
Then in the plugin, when I call
const UFoobarSettings* Settings = GetDefault<UFoobarSettings>()
…sure enough, Settings->Prop1
is 111
and Settings->Prop2
is 222
. Then, if I call
UFoobarSettings* Settings = GetMutableDefault<UFoobarSettings>();
Settings->Prop1 = 123;
Settings->SaveConfig();
…then a file MyGame/Saved/Config/Windows/Foobar.ini
is created with the contents
[/Script/Foobar.FoobarSettings]
Prop1=123
…and indeed, the next time I call GetDefault<UFoobarSettings>()
it will return an object that has Prop1
with 123
and Prop2
with 222
. This all makes sense to me.
When I look at other plugins, though, like the Niagara plugin, it has a file called MyGame/Config/DefaultNiagara.ini
and a file in the engine called Engine/Plugins/FX/Niagara/Config/BaseNiagara.ini
as well. In the case of Niagara, it seems like the UNiagaraSettings
class similarly has Config=Niagara
set on it (although it also has defaultconfig
too). When the Niagara module calls GetDefault<UNiagaraSettings>()
, it gets a UNiagaraSettings
object that has the settings from Engine/Plugins/FX/Niagara/Config/BaseNiagara.ini
in it.
Moreover, with Niagara, when I make a change to the settings in Project Settings->Plugins->Niagara, I notice that there’s a new file at MyGame/Saved/Config/Windows/Niagara.ini
. BUT, that file is EMPTY and the settings change has gone into MyGame/Config/DefaultNiagara.ini
. AND the settings UI has a little message that says,
These settings are saved in DefaultNiagara.ini which is currently writable
…which I would assume is referring to MyGame/Config/DefaultNiagara.ini
?
When I try to create MyGame/Plugins/Foobar/Config/BaseFoobar.ini
, it gets ignored. So with my plugin, I have
MyGame/Plugins/Foobar/Config/BaseFoobar.ini
(ignored)
Engine/Config/BaseFoobar.ini
(ignored)
Engine/Config/Windows/BaseFoobar.ini
(ignored)
MyGame/Plugins/Foobar/Config/DefaultFoobar.ini
(populates default object)
MyGame/Saved/Config/Windows/Foobar.ini
(holds changed settings from SaveConfig()
)
and with Niagara I have
Engine/Plugins/FX/Niagara/Config/BaseNiagara.ini
(populates default object)
MyGame/Config/DefaultNiagara.ini
(holds changed settings)
MyGame/Saved/Config/Windows/Niagara.ini
(empty)
Can anyone help me make sense of this? Plugins seem to work very differently than game settings? Should my plugin somehow be using a BaseFoobar.ini
file? How does that work? I could probably just ship what I have with a MyGame/Plugins/Foobar/Config/DefaultFoobar.ini
file for settings, but I have an uneasy feeling that I’m misusing DefaultFoobar.ini
in some way.