1.新建一个类 继承自 UActorComponent
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "MyActorComponent.generated.h"
UENUM(BlueprintType)
enum class EPRG_PropertyName : uint8
{
EPropertyHp UMETA(DisplayName = "Hp"),
EPropertyExp UMETA(DisplayName = "Exp"),
EPropertyLevel UMETA(DisplayName = "Level")
};
USTRUCT(BlueprintType)
struct FRPG_PropertyValue
{
GENERATED_USTRUCT_BODY()
UPROPERTY(BlueprintReadWrite, EditAnywhere)
float Min;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
float Current;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
float Max;
};
UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent), Blueprintable)
class ACTIONRPG_API UMyActorComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UMyActorComponent();
protected:
// Called when the game starts
virtual void BeginPlay() overr