How it works...

As with most of the recipes in this chapter, we use GameMode to create and display our UI to minimize the number of classes that are extraneous to the point of the recipe that you need to create.

Within our new game mode, we need to retain references to the Slate Widgets that we create so that we can interact with them after their creation.

As a result, we create two shared pointers as member data within our GameMode one to the overall parent or root widget of our UI, and the other to the label on our button, because we're going to be changing the label text at runtime later.

We override BeginPlay, as it is a convenient place to create our UI after the game has started, and we will be able to get valid references to our ...

Get Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.