How it works...

Console commands are usually provided by a module. The best way to get the module to create the command when it is loaded is to place the code in the StartupModule method.

IConsoleManager is the module that contains the console functionality for the engine.

As it is a sub-module of the core module, we don't need to add any additional information to the build scripts to link in additional modules.

To call functions within the console manager, we need to get a reference to the current instance of IConsoleManager that is being used by the engine. To do so, we invoke the static Get function, which returns a reference to the module in a similar way to a singleton.

RegisterConsoleCommand is the function that we can use to add a ...

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.