Error when calling FGameStyles::Get()

Hello everyone, i have an error when i try to get Style

&FGameStyles::Get().GetWidgetStyle(“Style”);

Error appears here:

What should i do?

hmm, i think i found a problem, gonna check, i have initialised, but i think i made mistake there

What does the error say?

It seems that you’ve not initialised your style instance (your Get() call doesn’t do this), so it’s causing a crash accessing a null pointer.

It should just be a case of calling FGameStyles::Initialize() when your module is loaded (and FGameStyles::Shutdown() when your module is unloaded).

This is how the ShooterGame sample handles it:

class FShooterGameModule : public FDefaultGameModuleImpl
{
	virtual void StartupModule() override
	{
		FSlateStyleRegistry::UnRegisterSlateStyle(FShooterStyle::GetStyleSetName());
		FShooterStyle::Initialize();
	}

	virtual void ShutdownModule() override
	{
		FShooterStyle::Shutdown();
	}
};

IMPLEMENT_PRIMARY_GAME_MODULE(FShooterGameModule, ShooterGame, "ShooterGame");

If you search for IMPLEMENT_PRIMARY_GAME_MODULE you should find where your own games module is defined in code.

Your IMPLEMENT_PRIMARY_GAME_MODULE is using FDefaultGameModuleImpl rather than your FDisasterGameModule.

dont know why doesnt work

alright, it’s working, thank you very much and sorry, was my bad