Plugin Configs

This page shows it should be possible to add Configs to each plugin.

[PluginName]/Config/Default[PluginName].ini

So if I have a plugin named MyPlugin I tried creating a file under Config/DefaultMyPlugin.ini

However none of the settings set in there seem to take effect. I’m not sure this is completely right or working.

1 Like

Is the plugin valid for the version you are using? Perhaps the plugin you are trying to install is only supported for older versions?

I use GConfig which is a FConfigCacheIni (FConfigCacheIni | Unreal Engine Documentation)

It saves the config in the users project rather than the plugin folder - I thought that was more in line with UE - it’s easy enough to create “Import from another project” features.

To load it initially:

if(!FConfigCacheIni::LoadGlobalIniFile(myConfigIni,TEXT("MyConfig"))) {
		UE_LOG(LogTemp, Display,TEXT("Failed to load config ini file"));
}

Then it’s this easy to set something:

	FString str=TEXT("My Value to Save");
	check(GConfig && GConfig->IsReadyForUse());
	GConfig->SetString(TEXT("MySection"),TEXT("MyKey"),*str,myConfigIni);
	GConfig->Flush(0);

And to Read:

	FString str;
	check(GConfig && GConfig->IsReadyForUse());
	if(!GConfig->GetString(TEXT("MySection"),TEXT("MyKey"),str,myConfigIni)) {
		return false;
	}

This is my own plugin that I’m building in C++ and I’m trying to figure out how to make my plugin come with its own default config so you don’t have to remember to add these configs to the game every time you add it.

Ideally I’d want this to be the default setting unless it’s overridden by the game. Otherwise the plugin isn’t just, Drop in and Plug and Play. You have to add all these additional cumbersome steps like, “Don’t forget to copy paste this into your DefaultGame.ini”

Also this is a plugin that lives in the game’s Plugins folder. It could potentially be in the engine plugins, but for this I’m choosing to make it live with the game. I actually figured out how to work with unreal plugins and C++ pretty well, but am struggling with this config issue.

1 Like

Did you ever figure this out? I’m running into the same issue and it’s been quite a headache!

Any help is appreciated!

1 Like

I was having this issue with Gameplay Tags and ended up defining all the gameplay tags in a table asset and have to add the file in the project settings. I found that I could add code into the module startup to add an ini file to the tags search path.

However, I ran into an issue where if my plugin loaded the configs at plugin load time the gameplay tags were loaded too late for some things the engine required.

Specifically platform trait tags in common UI.

It sounds like RecourseDesign’s code might work too.

Thanks. Yeah in my case I tried a bunch of things.

RecourseDesign’s answer was also helpful.

In my particular scenario I couldn’t load the config file with LoadGlobalIniFile, but since i know where that file is in relation to my plugin’s base directory, i was able to do:

FConfigFile configFile; 
configFile.Read(<pathToYourFile>);

if (!configFile.isEmpty())
{
  configFile.GetString(...);
}

Then using RecourseDesign’s suggestion to access my sections and strings within that section.

I also did this in my plugin’s StartupModule function

I had the same issue with the platform traits and Common UI. The way I fixed it was to set my module’s load phase to pre default:

"LoadingPhase": "PreDefault" (in your plugin’s .uproject file)

The reason why that works is because CommonUI is set to load in the default phase:

		{
			"Name" : "CommonUI",
			"Type" : "Runtime",
			"LoadingPhase" : "Default"
		},

So by forcing our plugin to load earlier, the game tags are available by the time CommonUI (or whatever plugin might use your tags/config) loads. Of course that only works if your target plugin does load after the PreDefault phase.

If you don’t that, the load order isn’t guaranteed and your tags might not be available.

1 Like

I guess it’s possible to create a module only for tags and have its config be set to load at the right time. That way if your module can’t load early, at least the tags module can.

I noticed that this documentation no longer exists for UE5.

1 Like