I have a shader plugin, which has to load at the PostConfigInit stage.
During the StartupModule function, if I try to get the Settings module it just drops straight out of the function.
If I check if it’s loaded and load it if it isn’t, I get the settings interface back. However, then when I try to register the default object of my settings class from within my module I get an assert when it tries to get the DefaultMutableObject for my class. The code looks a bit like this:
FModuleManager& ModuleManager = FModuleManager::Get();
ISettingsModule* settingsModule = NULL;
if (!ModuleManager.IsModuleLoaded("Settings"))
{
settingsModule = (ISettingsModule*)ModuleManager.LoadModule("Settings");
}
else
{
settingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");
}
if (settingsModule)
{
UObject* default = GetMutableDefault<UMySettings>(); // *** ASSERT HERE ***
auto settingsSection = settingsModule->RegisterSettings("Project", "Plugins", "MyPlugin",
LOCTEXT("MyPluginName", "MyPlugin"),
LOCTEXT("MyPluginDescription", "Configure MyPlugin."),
default
);
// etc
}
The error given is:
LogWindows: Error: === Critical error: ===
LogWindows: Error:
LogWindows: Error: Assertion failed: Internal::GObjInitialized [File:D:\Build++UE4+Release-4.18+Compile\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp] [Line: 171]
In other examples and samples I have found of this, none of them are doing at the PostConfigInit stage. So, I wonder if there’s something else that needs to be up and running before the settings system will work?
I suspect I am just doing something daft.
If there’s another sensible place I can register this, where would it be?
Thanks & regards,
Robert