Note: Before you get started please note that this method will NOT work in shipping builds as Cheat Manager is stripped from them. For a method which does work in Shipping builds, check out my newer post: Taking In-Game Screenshots With UI in Shipping builds of UE4 Games.

Taking screenshots in Unreal is super easy, you just open the console and type “HighResShot”. But what if you wanted more?

What if you wanted to use the in-game camera with “ToggleDebugCamera” AND capture any UMG widgets on the UI? Well, we can do that but first, we need to use some C++.

If you don’t have a C++ project already, go ahead and make one or convert your current one with File->New C++ Class.

Once that’s done, you’ll need to create a new Cheat Manager class.

You’ll notice two cheat managers in the screenshot, not to worry, one is mine.

You want to select Cheat Manager and select Create Class, wait for Unreal to compile and then we can get into it. We’re using the Cheat Manager as it’s designed for this sort of thing.

Open your Cheat Manager header file and below your GENERATED_BODY(), insert:

UFUNCTION(Exec, BlueprintCallable)
static void TakeScreenShot();

Then in your cpp file:

void UMyCheatManager::TakeScreenShot()
{
    FScreenshotRequest * request = new FScreenshotRequest();
    request->RequestScreenshot("ScreenShot", true, false);
    if(request->IsScreenshotRequested())
    {
        FString ResponseMessage = TEXT("Screenshot saved to: " + request->GetFilename());
        FWindowsPlatformMisc::MessageBoxExt(EAppMsgType::Ok, *ResponseMessage, TEXT("Screenshot Taken"));
    }
}

Now just recompile, play your game, toggle the debug camera and type into the console “TakeScreenShot“. Now you have a screenshot with UI!

But what does it all do?

Good question!

UFUNCTION(Exec, BlueprintCallable)

Exec = Allows it to be executed from the console.
BlueprintCallable = Allows me to call it from a blueprint node if I wish.

FScreenshotRequest * request = new FScreenshotRequest();

As you can probably guess: this creates a new Screenshot Request object. This is how the engine knows when you want a screenshot.

request->RequestScreenshot("ScreenShot", true, false);

From that request object, you call RequestScreenshot() to actually make the request and the engine will handle the rest.

BUT we can see three arguments there, what are they? Easy, but let’s break it down:

RequestScreenshot(
    "ScreenShot", //The output filename
    true, //This one toggles to show the UI, the real star of this post.
    false //Toggles the filename suffix, more on that below.
);

So the filename suffix…you thought that was gonna be lower didn’t you? I guess I pulled a sneaky on ya.

If the Filename Suffix toggle was set to true your screenshots will be appended with 00000, 00001, 00002, 00003 and so on…
Toggling it to false disables that as I use my own system of appending the current date. On or off? It’s up to you. On is the default for the built-in screenshot tools.

That’s all you need to get going but you’ll notice a little bit of sneaky code in there:

    if(request->IsScreenshotRequested())
    {
        FString ResponseMessage = TEXT("Screenshot saved to: " + request->GetFilename());
        FWindowsPlatformMisc::MessageBoxExt(EAppMsgType::Ok, *ResponseMessage, TEXT("Screenshot Taken"));
    }

I’ll get through this quickly as it’s not really necessary but it a bit convinient.
You see; if we take a screenshot, sometimes Unreal is a bit too quick and will include the console in the screenshot too, we don’t want that. All this does is:

    if(request->IsScreenshotRequested())
/* Checks if a screenshot has already been requested,
 not sure how we can get here without it being requested but it's a safety thing more than anything. */
    {
        FString ResponseMessage = TEXT("Screenshot saved to: " + request->GetFilename());
//Creates a string for a pop-up message box

        FWindowsPlatformMisc::MessageBoxExt(EAppMsgType::Ok, *ResponseMessage, TEXT("Screenshot Taken"));
//Displays the message box.
    }

This, essentially, slows down the taking of the screenshot just enough to make sure the console has been closed. This is more of a bandage over a bigger problem though, so no guarantees.

Now just compile it, open your PlayerController class and find the Cheat Manager entry in its defaults and change the Cheat Class to MyCheatManager. You may need to restart Unreal for it to show up.

And there you have it, just launch your project in PIE, toggle the debug camera and the type into the console TakeScreenShot, and you’ve got your screenshot with UI.