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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.