When launching the editor, I get the call to Initialize in world subsystem a couple of times as it’s loading. This is happening because the editor creates two worlds as part of the boot process. The first is an empty world created in UEngine::Init and the second is whatever real map it loads on startup. It also does this every time you change the map in the editor.
Is there a way to detect this? This is sort of the equivalent of a CDO init but in this case the subsystem is not the default object and so I can’t check that.
Yeah, my issue is that Initialize is being called every time a world is opened in the editor. My Initialize contains a bunch of processing that’s only relevant at runtime so there’s no reason to do it at editor time. I’m asking if there’s a way to differentiate between Initialization calls that happen at runtime vs those that are editor only.
In this case you don’t need to manually check to tell the difference.
What you want to do is override bool UWorldSubsystem::DoesSupportWorldType(const EWorldType::Type WorldType) const; so that it returns true only for EWorldType::Game and EWorldType::PIE.
The default behavior of ShouldCreateSubsystemwill figure out and use DoesSupportto figure out if your subsystem should run.