Keys not being read from GConfig

Hey all,

I’m running into an issue where I can’t read a key from a config file.

Essentially, it returns null. Within the .ini file is this:
[/Script/MyProject.GlobalSettings]
MasterItemList=/Game/Item.Item

I’ve double-checked to make sure the directory is correct and the file is there.

The function:

FString FMyModule::GetConfigValue()
{
	FString Value = "Null";

	if (!GConfig)
	{
		Value = "Congif not found!";
		return Value;
	}

	GConfig->GetString(TEXT("[/Script/MyProject.GlobalSettings]"), TEXT("MasterItemList"), Value, FPaths::GeneratedConfigDir().Append("DefaultGame.ini"));

	return Value;
}

It’s called on startup like this:

FString Value = GetConfigValue();
UE_LOG(LogTemp, Error, TEXT("Master Item List: %s"), *Value);

I appreciate any advice.

1 Like