Spawn Actor From Data Table FilePath

You need to make a pointer to your datatable exposed to Blueprint so you can select the correct datatable

UPROPERTY(EditDefaultsOnly)
class UDataTable* MyDataTable;

then in your code:

if (MyDataTable)
{
    FMyDataTableStruct* MyDataTableRow = MyDataTable->FindRow<FMyDataTableStruct>("RowNameHere", "ContextString"); 

   if (MyDataTableRow)
   {
            MyDataTableRow->Class
   }
}

If you want to get all rows you can do the following:

if (MyDataTable)
{
			TArray<FMyDataTableStruct*> OutRows;
			MyDataTable->GetAllRows<FMyDataTableStruct>("ContextString", OutRows);
			for (FMyDataTableStruct* Row : OutRows)
			{
				Row->Class;
			}
}

Hope this helps

1 Like