使用ue4的数据表操作


1,想创建一个表结构继承 FTableRowBase

USTRUCT(BlueprintType)
struct Ftest:public FTableRowBase
{
    GENERATED_USTRUCT_BODY()

    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Item)
        int32 id;
};

2,然后创建表格文件(testbp),在编辑器,右键-其他-数据表格 选择你创建的类作为构造对象,

3,,加载这表格文件并使用,

ConstructorHelpers::FObjectFinder<UDataTable> _test_BP(TEXT("DataTable'/Game/testbp'"));

class UDataTable* _testTable = _test_BP.Object;

static const FString Context = FString(TEXT("Trying to read row"));

读取单行

Ftest* testRow= _testTable->FindRow<Ftest>(FName(一行的名字),Context);

读取多行

TArray<Ftest*>testRowsData;
 _testTable->GetAllRows<Ftest>(FString(TEXT("test")), testRowsData);

这样我们就可以根据条件循环去数组里查找数据了


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM