Programatically pause editor (PIE/SIE)

Is it possible to pause the UE4 Editor from C++, when I Play/Simulate In Editor?

Note that I am not looking to pause the game the way a player would pause it. Instead I really want to pause the editor, as if I pressed the pause button on the toolbar.

I am debugging some physics settings and would like to pause the editor exactly when a collision/overlap happens. Of course I can set a breakpoint in my code, but then I cannot see the scene, “Eject”, zoom in, etc. If I have to press the “Pause” button myself, I won’t be able to pause it at the exact right time.

Thanks in advance!

Have you tried the “pause” command? Simply open the console and input “pause”. That’s kind of the way the player would do it, but then you can press eject and move around with the camera in the editor.

If you want to trigger it in code when you get a collision for example, you can use this :

GEngine->DeferredCommands.Add(TEXT("pause"));

Hope this is what you are looking for!

1 Like

Hi Michaël, thanks for you quick response! Unfortunately this isn’t really what I am looking for. Invoking the “pause” command will show the pause menu and then I cannot see the scene anymore. I would really like to control the “Pause simulation” toolbar button.

Alright then, you can do this :

//Be sure to include UnrealEd.h
#if WITH_EDITOR
#include "UnrealEd.h"
#endif

#if WITH_EDITOR
	GUnrealEd->PlayWorld->bDebugPauseExecution = true;
#endif
1 Like

Thanks Michaël, you’re awesome! This was exactly what I was looking for :slight_smile:
Just had to add "UnrealEd" to my list of dependencies in ProjectName.Build.cs and it worked like a charm.

Inspired From MickD777’s answer, you can simply use:

GetWorld()->bDebugPauseExecution = true;

No need to link against UnrealEd or include UnrealEd.h.

3 Likes