我的需求:在UE4游戲工程里建立4種自定義表格
參考文檔: UE4.11 引擎自帶的代碼文件 GameplayTagsManager.h
/** Simple struct for a table row in the gameplay tag table */
USTRUCT()
struct FGameplayTagTableRow : public FTableRowBase
{
GENERATED_USTRUCT_BODY()
/** Tag specified in the table */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=GameplayTag)
FString Tag;
/** Text that describes this category - not all tags have categories */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=GameplayTag)
FText CategoryText;
/** Constructors */
FGameplayTagTableRow() { CategoryText = NSLOCTEXT("TAGCATEGORY", "TAGCATEGORYTESTING", "Category and Category"); }
FGameplayTagTableRow(FGameplayTagTableRow const& Other);
/** Assignment/Equality operators */
FGameplayTagTableRow& operator=(FGameplayTagTableRow const& Other);
bool operator==(FGameplayTagTableRow const& Other) const;
bool operator!=(FGameplayTagTableRow const& Other) const;
};
我的頭文件 WeaponDataTable.h
#pragma once
#include "WeaponDataTable.generated.h"
USTRUCT()
struct FWeapon_Entry : public FTableRowBase
{
GENERATED_BODY()
/** Tag specified in the table */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = GameplayTag)
FString Tag;
/** Text that describes this category - not all tags have categories */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = GameplayTag)
FText CategoryText;
/** Text that describes this category - not all tags have categories */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = GameplayTag)
FText CategoryText1;
/** Text that describes this category - not all tags have categories */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = GameplayTag)
FText CategoryText2;
/** Text that describes this category - not all tags have categories */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = GameplayTag)
FText CategoryText3;
};
USTRUCT()
struct FWeapon_Client : public FTableRowBase
{
GENERATED_BODY()
/** Tag specified in the table */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = GameplayTag)
FString Tag;
/** Text that describes this category - not all tags have categories */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = GameplayTag)
FText CategoryText;
};
USTRUCT()
struct FWeapon_Spell_Entry : public FTableRowBase
{
GENERATED_BODY()
/** Tag specified in the table */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = GameplayTag)
FString Tag;
/** Text that describes this category - not all tags have categories */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = GameplayTag)
FText CategoryText;
};
USTRUCT()
struct FWeapon_Spell_Client : public FTableRowBase
{
GENERATED_BODY()
/** Tag specified in the table */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = GameplayTag)
FString Tag;
/** Text that describes this category - not all tags have categories */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = GameplayTag)
FText CategoryText;
};
我的對應(yīng)的cpp文件
#include "YourProjName.h" //你的項目頭文件
#include "WeaponDataTable.h"
最終效果

看,自定義表格成功
結(jié)論:
數(shù)據(jù)表在代碼層面也是結(jié)構(gòu)體,明白這一點,那么就不難理解上面代碼結(jié)構(gòu)體名和最終數(shù)據(jù)表可選類型的對應(yīng)關(guān)系。本帖將要推出
- 用藍(lán)圖實現(xiàn)數(shù)據(jù)表
- C++細(xì)說數(shù)據(jù)表內(nèi)容