Accessing a UPROPERTY
from Blueprints is fairly simple. The member must be exposed as a UPROPERTY
on the member variable that you want to access from your Blueprints diagram. You must qualify the UPROPERTY
in your macro declaration as being either BlueprintReadOnly
or BlueprintReadWrite
to specify whether you want the variable to be either readable (only) from Blueprints, or even writeable from Blueprints.
You can also use the special value BlueprintDefaultsOnly
to indicate that you only want the default value (before the game starts) to be editable from the Blueprints editor. BlueprintDefaultsOnly
indicates the data member cannot be edited from Blueprints at runtime.
UObject
-derivative class, specifying both Blueprintable
and BlueprintType
, such as the following:UCLASS( Blueprintable, BlueprintType ) class CHAPTER2_API UUserProfile : public UObject { GENERATED_BODY() public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Stats) FString Name; };
The BlueprintType
declaration in the UCLASS
macro is required to use the UCLASS
as a type within a Blueprints diagram.
UPROPERTY
are automatically written Get
/Set
methods for UE4 classes. They must not be declared as private
variables within the UCLASS
, however. If they are not declared as public
or protected
members, you will get a compiler error of the form:
>> BlueprintReadWrite should not be used on private members
52.14.134.130