Check if "Simulate in Editor"?

Hi! I want to detect in my code if the play mode is set to “Play” (Selected Viewport) or “Simulate in Editor”. I know I can get information about the world type through “GetWorld()->WorldType” but it returns “PIE” for both “Play” and “Simulate in Editor”. Is there any other way to distinguish them?

You can check the UEditorEngine’s bIsSimulatingInEditor property, like this:

if (UEditorEngine* editor = CastChecked<UEditorEngine>(GEngine))
    return editor->bIsSimulatingInEditor;
return false;

Not working at all. If there is Cast - project not compiling with LNK2019, if you write just (UEditorEngine*)GEngine - then it’s always nullptr.

Are you including EditorEngine.h?

It’s more like this actually:

bool myClass::IsPIE() const {
      return ( GEditor->bIsSimulatingInEditor || ( GEditor->PlayWorld != NULL ) );

Thank you! That works perfectly.
Also include for this “Editor.h” and module “UnrealEd” goes to .Build.cs file.