How to do it...

  1. Create some UObject-derivative class, specifying both Blueprintable and BlueprintType, such as in the following code, using the same class we created previously:
/** * UCLASS macro options sets this C++ class to be * Blueprintable within the UE4 Editor */UCLASS(Blueprintable, BlueprintType)class CHAPTER_02_API UUserProfile : public UObject{  GENERATED_BODY()public:  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Stats)  float Armor;  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Stats)  float HpMax;  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.

  1. Save and compile ...

Get Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition 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.