DataTableRowHandle to Get Data table row: Only literal data table is supported

Hi,

I’ve found a workaround to this issue.

I found these codes from answer hub a while ago, I can’t find original post though, so I just post it here.

And I’ve made some modifications to it to prevent some crash issue.

Create a C++ blueprint function library and add these codes:

.h

UFUNCTION(BlueprintCallable, Category = "DataTable")
	static FEnemyFireStruct GetRowByName(UDataTable* dataTable, FName pName, bool& result); 

.cpp

FEnemyFireStruct UUBPFuncLib::GetRowByName(UDataTable* dataTable, FName pName, bool& result)
{
	result = true;
	FEnemyFireStruct* data = dataTable->FindRow<FEnemyFireStruct>(pName, "", false);
	if (data == NULL)
	{
		result = false;
		return FEnemyFireStruct();
	}

	return *data;
}

FEnemyFireStruct is my custom struct, you can replace with your own struct.

Then you can create a data table handle in blueprint, assign data table to it.

By using this way you can have multiple child share one common parent with same code base and can still assign different data table value to different child.

This isn’t entirely beautiful because you have to create a new function for each struct you want to use, but this is the only option I found workable currently.

47596-dt1.png

1 Like