Creating a UFUNCTION
UFUNCTION()
are useful because they are C++ functions that can be called from both your C++ client code as well as Blueprints diagrams. Any C++ function can be marked as a UFUNCTION()
.
How to do it...
- Construct a
UClass
with a member function that you'd like to expose to Blueprints. Decorate that member function withUFUNCTION( BlueprintCallable, Category=SomeCategory)
to make it callable from Blueprints. For example, the following is theWarrior
class again:// Warrior.h class WRYV_API AWarrior : public AActor { GENERATED_BODY() public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Properties) FString Name; UFUNCTION(BlueprintCallable, Category = Properties) FString ToString(); }; // Warrior.cpp FString UProfile::ToString() ...
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.