Download

Editor Plugin : how to get know if the game is running at all?

Hello,

my plugin has an editor and a runtime component. When accessing data, I need a WorldContext object frequently.
At runtime, I just pass my actors, which is fine. The editor part (manipulation of DataAssets with a custom editor via Slate) needs to access functions that require a WorldContext as well.
Now, I do know I can get the Editor World via GEditor->GetWorldContext().World.
However, I need to define what world context objects I use differently depending on if the game is running or not.

If we are in game, I want to pass an object of the loaded map, if we are not (meaning we are in editor), I want to use the Editor UWorld.

The known preprocessor directives “#if WITH_EDITOR” or “#if WITH_EDITORDATA_ONLY” do not help because they tell me what the build is, not whether the game is running (no matter if PIE, Standalone etc.) or not.

How to know if the game is running at all?

Check world type?
e.g. Is it Game/PIE instead of Preview

That would imply the game is running so I can check the world of, for example, an actor.

I managed to find a workaround though for my specific problem.