Canvas is a continuation of the simple HUD implemented within Unreal 3. While it isn't so commonly used within shipping games, mostly being replaced by Slate/UMG, it's simple to use, especially when you want to draw text or shapes to the screen. Canvas drawing is still used extensively by console commands used for debugging and performance analysis such as the stat game
and other stat
commands. Refer to Chapter 8, Integrating C++ and the Unreal Editor, for the recipe for creating your own console commands.
Open your
<Module>.build.cs
file, and uncomment/add the following line:PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
Create a new
GameMode
calledCustomHUDGameMode
using the editor class wizard. Refer to Chapter 4, Actors and Components, if you need a refresher on doing this.Add a constructor to the class:
ACustomHUDGameMode();
Add the following to the constructor implementation:
ACustomHUDGameMode::ACustomHUDGameMode...