- 结构:
USTRUCT(BlueprintType)
struct FPlayerAttackMontage : public FTableRowBase {
GENERATED_USTRUCT_BODY()
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Animation, meta = (AllowPrivateAccess = true))
class UAnimMontage* MeleeAttackMontage;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
int AnimSectionCount;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FString Descrtion;
};
- 建立
#include "Engine/DataTable.h"
//下面代码 放构造函数里
static ConstructorHelpers::FObjectFinder<UDataTable> PlayerAttackMontageDataObject(TEXT("DataTable'...'"));
if (PlayerAttackMontageDataObject.Succeeded()) {
PunchAttackTable = PlayerAttackMontageDataObject.Object;
}
- 寻找:
//DataTable 寻找 FindRow class UDataTable* PunchAttackTable;
static const FString ContextString(TEXT("Player Attack Montage Context"));
FPlayerAttackMontage* AttackMontage = PunchAttackTable->
FindRow<FPlayerAttackMontage>(FName("d02"), ContextString, true);
if (AttackMontage) {}