Ensure that you've followed the previous recipe in order to have a UInterface
ready to be implemented.
Actor
class using the Unreal Wizard, called SingleInterfaceActor
.IInterface
—in this case, IMyInterface
—to the public inheritance list for our new Actor
class:class UE4COOKBOOK_API ASingleInterfaceActor : public AActor, public IMyInterface
override
declaration to the class for the IInterface
function(s) that we wish to override:FStringGetTestName() override;
FStringASingleInterfaceActor::GetTestName() { return IMyInterface::GetTestName(); }
SingleInterfaceActor
class, where we add public IMyInterface
.IInterface
rather than UInterface
to prevent SingleInterfaceActor
from inheriting two copies of UObject
.virtual
function, we need to redeclare that function with the override specifier if we wish to implement it ourselves.virtual
function.IInterface
implementation of the function. Alternatively, we could write our own implementation, and avoid calling the base class one altogether.IInterface:: specifier
rather than Super
, because Super
refers to the UClass
that is the parent of our class, and IInterfaces aren't UClasses (hence, no U
prefix). 3.139.104.214