-
Book Overview & Buying
-
Table Of Contents
Unreal Engine 4 Scripting with C++ Cookbook
By :
One advantage that UInterfaces provides you with as a developer is the ability to treat a collection of heterogeneous objects that implement a common interface as a collection of the same object, using Cast< > to handle the conversion.
Please note that this won't work if your class implements the interface through a Blueprint.
You should have a UInterface, and an Actor implementing the interface ready for this recipe.
Create a new game mode using the wizard within Unreal, or optionally, reuse a project and GameMode from a previous recipe.
Open your game mode's declaration, and add a new UPROPERTY() macro to it:
UPROPERTY() TArray<IMyInterface*>MyInterfaceInstances;
Add #include "MyInterface.h" to the header's include section.
Add the following within the game mode's BeginPlay implementation:
for (TActorIterator<AActor> It(GetWorld(), AActor::StaticClass()); It; ++It)
{
AActor* Actor = *It;
IMyInterface...
Change the font size
Change margin width
Change background colour