I created a class to store project settings, but when I attempt to read one I get the following fatal error:
Short config section used instead of long MyPlugin.MyPluginSettings
#pragma once
#include "CoreMinimal.h"
#include "MyPluginSettings.generated.h"
UCLASS(config=Engine, defaultconfig, meta=(DisplayName="My Plugin's Settings"))
class MYPLUGIN_API UMyPluginSettings : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(config, EditAnywhere)
bool bEnabled;
};
// ----------
void UMyPluginBPLibrary::ReadProperty()
{
bool bEnabled;
if(GConfig->GetBool(TEXT("MyPlugin.MyPluginSettings"), TEXT("bEnabled"), bEnabled, GEngineIni))
{
UE_LOG(LogTemp, Warning, TEXT("MyPlugin.Settings: bEnabled: %d"), bEnabled);
}
else
{
UE_LOG(LogTemp, Error, TEXT("Failed to read property"));
}
}
If I shorten it from “MyPlugin.MyPluginSettings” to “MyPluginSettings” it does not crash, but it fails to read the propertly.