UInterfaces are a pair of classes that work together to enable classes to exhibit polymorphic behavior among multiple class hierarchies. This recipe shows you the basic steps involved in creating a UInterface
purely in code.
UInterfaces don't show up inside the main class wizard within Unreal, so we'll need to add the class manually using Visual Studio.
Right click on your Source folder inside Solution Explorer, and select Add | New Item.
Select a
.h
file to start, and name itMyInterface.h.
Make sure you change the directory for the item to be placed in from Intermediate to Source/ProjectName.
Click on OK to create a new header file in your project folder.
Repeat the steps in order to create
MyInterface.cpp
as your implementation file.Add the following code to the header file:
#include "MyInterface.generated.h" /** */ UINTERFACE() class UE4COOKBOOK_API UMyInterface: public UInterface { GENERATED_BODY() }; /** */ class UE4COOKBOOK_API IMyInterface { ...