Need help for making Singleton style UObject and other problems.

If you double-click GameManagerBP in content browser you can set the defaults. Just in case you’re not aware. Also btw, if you change data in the singleton in-game, it will stay persistent even when you leave the game and only restarting the editor will reset it. Personally to get around that I manually reset the data in my GameMode EndPlay event.

wow another thank you for your information :smiley:

how do i reset manually the data in my Game Mode? I opened a reference and C++ and Gamemode does not have Endplay event. sorry for being noob again

trying to add in BP… might be working…

all of sudden, another instance of UObject(Animation Manager in my Singleton) is gone every time I hit play button… this is chaos :confused: why my singleton does not work as predicted…

There is a method you can override in your GameMode:


virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

So make a custom game mode in C++ inheriting from AGameMode and then override this method. Then you can do something like this:


void AYourGameMode::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
	Super::EndPlay(EndPlayReason);

	if (EndPlayReason == EEndPlayReason::EndPlayInEditor)
	{
		// Reset your data
	}
}

it is working again… what kind of sorcery is this :mad: anyway back to another work

thank you. Gigantoad you are the best!