Exposing UInterface methods to Blueprint from a native base class
Being able to define UInterface
methods in C++ is great, but they should be accessible from Blueprint too. Otherwise, designers or others who are using Blueprint won't be able to interact with your UInterface
. This recipe shows you how to make a function from an interface callable within the Blueprint system.
How to do it...
- Create a
UInterface
calledUPostBeginPlay
/IPostBeginPlay
. - Add the following
virtual
method toIPostBeginPlay
:UFUNCTION(BlueprintCallable, Category=Test) virtual void OnPostBeginPlay();
- Provide an implementation of the function:
voidIPostBeginPlay::OnPostBeginPlay() { GEngine->AddOnScreenDebugMessage(-1, 1, FColor::Red, "PostBeginPlay called"); }
- Create a new
Actor ...
Get Unreal Engine 4 Scripting with C++ Cookbook 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.