UDataTable pointer of specific type

I need a reference to a data table, so a pointer to UDataTable, but I also need to differentiate the struct this table is using.

As an example, I’ve got multiple data tables that use the same struct that contains some character information. If I want to access the data table rows in Blueprint and I pass in the data table pointer to “Get Data Table Row” the output is a wildcard, since no “subtype” is specified in a UDataTable pointer and I cannot cast structs to the one I need.

So how would I define a variable in C++ that represents a UDataTable that uses a specific struct as base?

1 Like

You can do it with meta tags in the UPROPERTY macro:

If your structure is called FStructName you have to remove the F in the tag:

UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(RequiredAssetDataTags = RowStructure=StructName))
UDataTable *DataTableName;

If you need to do it for a Row Handle you need to use this:

UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(RowType="StructName"))
FDataTableRowHandle RowHandle;

I noticed that these metatags don’t work inside other structs, so if you need to pass a specific DataTable type inside a struct it doesn’t work

1 Like