While marking classes as BlueprintType
or Blueprintable
allows us to pass instances of the class around in Blueprint, or to subclass the type with a Blueprint class, those specifiers don't actually say anything about member functions or variables, and if they should be exposed to Blueprint.
This recipe shows you how to mark a function so that it can be called within Blueprint graphs.
Create a new
Actor
class using the editor. Call the actorSlidingDoor
.Add the following
UPROPERTY
to the new class:UFUNCTION(BlueprintCallable, Category = Door) void Open(); UPROPERTY() bool IsOpen; UPROPERTY() FVector TargetLocation;
Create the class implementation by adding the following to the
.cpp
file:ASlidingDoor::ASlidingDoor() :Super() { auto MeshAsset = ConstructorHelpers::FObjectFinder<UStaticMesh>(TEXT("StaticMesh'/Engine/BasicShapes/Cube.Cube'")); if (MeshAsset.Object != nullptr) { GetStaticMeshComponent()->SetStaticMesh...