UCLASS
Blueprintable可创建蓝图BlueprintType可作为蓝图变量NotBlueprintType不可作为蓝图变量
UPROPERTY
EditAnywhere蓝图类和实例可编辑EditDefaultsOnly蓝图类可编辑EditInstanceOnly实例可编辑
BlueprintReadWrite蓝图类可读可写get/setBlueprintReadOnly蓝图类可读getBlueprintWriteOnly蓝图类可写set
UFUNCTION
BlueprintImplementableEvent:由蓝图实现。
UFUNCTION(BlueprintImplementableEvent)
void Jump();

BlueprintNativeEvent:c++实现默认功能,蓝图重写后调用蓝图的功能。
UFUNCTION(BlueprintNativeEvent)
void OnOverlap(AActor* OverlappedActor, AActor* OtherActor);
//绑定
OnActorBeginOverlap.AddDynamic(this, &ABaseCoin::OnOverlap);
void ABaseCoin::OnOverlap_Implementation(AActor* OverlappedActor, AActor* OtherActor) {
if (Cast<ABasePlayer>(OtherActor) != nullptr)
{
Destroy();
}
}

BlueprintCallable:可供蓝图调用的函数
UFUNCTION(BlueprintCallable)
void PlayCustomDeath();

创建和销毁UCLASS
UUserProfile* newobject = NewObject<UUserProfile>(GetTransientPackage(), UUserProfile::StaticClass());
if (newobject)
{
newobject->ConditionalBeginDestroy();
newobject = nullptr;
}
强制内存回收
GetWorld()->ForceGarbageCollection( true );
创建结构体
USTRUCT()
struct xxx_API FColoredTexture
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = HUD )
UTexture* Texture;
UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = HUD )
FLinearColor Color;
};
创建枚举
UENUM()
enum Status
{
Stopped UMETA(DisplayName = "Stopped"),
Moving UMETA(DisplayName = "Moving"),
Attacking UMETA(DisplayName = "Attacking"),
};