Taking In-Game Screenshots With UI in Shipping builds of UE Games

January 6, 2021

So you may remember a few months ago I made a post called Taking in-game screenshots with UI in Unreal Engine 4.

The problem with that post is that I was using the Cheat Manager for my implementation however, while suitable for my use case, this cannot be used in Shipping builds of your project due to Cheat Manager being one of the things UE4 strips from Shipping builds. This post will fix this in a quick and efficient way.

"So what's another way of doing it?" I hear you ask. Well, we could derive from quite a few classes but, for now, we'll derive from the Game Instance class.

Before we get into this I need to remind you of what the Game Instance is. It is the instance of your game.....yeah, that's an oversimplification. The Game Instance is the very first object created by the engine when the game is launched, after the engine's own initialisation of course, and is the final object to be destroyed when your game is closed. It exists for the entire time your game is running so it's the perfect place to put code you may always want access to which is why we're putting our new Screenshot implementation here.

So how do we do it?

Similar to the original post you need to add a new C++ class which is parented to the Game Instance class rather than Cheat Manager. Name it whatever you want.

The base Game Instance class

The base Game Instance class

Once that's been created and you've got it open in Visual Studio or Rider you'll need to add this code to the .h file:


1UFUNCTION(Exec, BlueprintCallable)
2static void TakeScreenShot(bool bCaptureUI, bool bAddSuffix);

And in the .cpp


1void UMyGameInstance::TakeScreenShot(bool bCaptureUI, bool bAddSuffix)
3	FString CurrentDateTime = FDateTime::Now().ToString(TEXT("%Y-%m-%d %H-%M"));
4	FScreenshotRequest* request = new FScreenshotRequest();
5	request->RequestScreenshot("ScreenShot " + CurrentDateTime, bCaptureUI, false);

Once that's done, hit compile and wait for the magic to happen. I won't go into much detail here as the code is pretty self-explanatory but if you want a more in-depth look at what's going on, check out my previous post titled; Taking in-game screenshots with UI in Unreal Engine 4.

So how do we use it?

Once that's compiled you'll need to do one small task before it's ready to go. This one's an easy one to miss if you haven't used a Game Instance before. You'll need to go into your Project Settings->Maps & Modes then scroll to the bottom to change your selected Game Instance to your newly created class.

Game Instance selector

Game Instance selector

You must do this step or the following WILL NOT work.

You can now go into any class you want, cast to your Game Instance and call TakeScreenshot from there. I'm using the Character as an example.

Calling TakeScreenshot from the new Game Instance

Calling TakeScreenshot from the new Game Instance

If you had not configured the project to use your custom Game Instance as shown above you will get an error when trying to use this cast.

A screenshot! Wow!

A screenshot! Wow!

Congrats! You can now take screenshots anywhere, even with UI. Sadly I didn't add UI to the project to show off. Please remember that this is a basic implementation and there are more extensive ways of taking screenshots with more features. This is just to get you going in the right direction.

If this helped you, please consider supporting me by buying me a coffee over on Ko-Fi at https://ko-fi.com/rhyce.

Or you could check out one of my other posts such as;

Controlling what happens on Fell Out Of World in UE4


How To Make Custom Unreal Engine Nodes Easily

Did this post help you?

Consider buying me a slice of pizza!