I have been working on a way to read Datatables for 2 days last week, and it seemed to work perfectly.
Only to find out when packaging these functions are not intended for packaged builds and only work in editor…
So I thought maybe I am stupid and I didn’t read the function declaration description properly. But I cannot find this information anywhere. So for every function I use from now on I have to package the game first before I can see if this function is supported in a build?
Maybe a good idea to add this kind of information somewhere so people do not waste time on creating a whole system on a function that can not be used in the game. For example with ALL CAPS in the function declaration description in C++. So people see that before they build a system around them.
Functions are from UDataTable, called GetTableData and GetColumnTitles. now there are no similar functions that work for a build so now I have to think of a whole new system. Please show me where this is documented so I can blame myself for not reading in on it properly.
Is there anyway to get these functions working for building? You probably need source code access for that right? Why am I not able to use them anyway?
So I fixed this by copying the logic from the source code functions to my own class. Which works fine, just still not sure why these are editor only functions.
For example like this where AFilterManager is my own class where I want to use it:
TArray<FString> AFilterManager::GetColumnTitles(UDataTable* DT) const
{
TArray<FString> Result;
Result.Add(TEXT("Name"));
for (TFieldIterator<UProperty> It(DT->RowStruct); It; ++It)
{
UProperty* Prop = *It;
check(Prop != NULL);
const FString DisplayName = DataTableUtils::GetPropertyDisplayName(Prop, Prop->GetName());
Result.Add(DisplayName);
}
return Result;
}
TArray<TArray<FString>> AFilterManager::GetTableData(UDataTable* DT, const EDataTableExportFlags InDTExportFlags) const {
TArray< TArray<FString> > Result;
// First build array of properties
TArray<UProperty*> StructProps;
for (TFieldIterator<UProperty> It(DT->RowStruct); It; ++It)
{
UProperty* Prop = *It;
check(Prop != NULL);
StructProps.Add(Prop);
}
// Now iterate over rows
for (auto RowIt = DT->RowMap.CreateConstIterator(); RowIt; ++RowIt)
{
TArray<FString> RowResult;
FName RowName = RowIt.Key();
RowResult.Add(RowName.ToString());
uint8* RowData = RowIt.Value();
for (int32 PropIdx = 0; PropIdx < StructProps.Num(); PropIdx++)
{
RowResult.Add(DataTableUtils::GetPropertyValueAsString(StructProps[PropIdx], RowData, InDTExportFlags));
}
Result.Add(RowResult);
}
return Result;
}