Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition
by John P. Doran, William Sherif, Stephen Whittle
How it works...
As with most of the other recipes in this chapter, we are using a custom GameMode class to display our single-player UI on the player's viewport for convenience.
We override BeginPlay and EndPlay so that we can correctly handle the timer that will be toggling our UI on and off for us. To make that possible, we need to store a reference to the timer as a UPROPERTY to ensure it won't be garbage collected.
Within BeginPlay, we create a new VerticalBox using the SNew macro, and place a button in its first slot. Buttons have Content, which can be some other widget to host inside them, such as SImage or STextBlock.
In this instance, we place an STextBlock into the Content slot. The contents of the text block are irrelevant, that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access