Hi, I’m trying to get a value from a row in my datatable, but I keep getting the error:
LogDataTable: Error: UDataTable::FindRow : '(null)' specified incorrect type for DataTable '/Game/Skills/DT_Skills.DT_Skills'.
DataTable:
Structure:
Structure code:
USTRUCT(BlueprintType)
struct FMyMiningDataTableRow : public FTableRowBase {
GENERATED_BODY()
int32 CurrentLevel;
int32 CurrentMaxLevel;
int32 MaxLevel;
UTexture2D* Icon;
float CurrentExperience;
float ExpRequirement;
ESKILL_TYPE SkillNameEnum;
};
Get row code:
void UMiningCharacterComponent::BeginPlay()
{
FStringAssetReference AssetRef("DataTable'/Game/Skills/DT_Skills.DT_Skills'");
DataTable = Cast<UDataTable>(StaticLoadObject(UDataTable::StaticClass(), nullptr, *AssetRef.ToString()));
FMyMiningDataTableRow* MyDataRow = DataTable->FindRow<FMyMiningDataTableRow>(FName("Mining"), nullptr, true);
if (MyDataRow != nullptr) {
MiningLevel = MyDataRow->CurrentLevel;
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("Error Getting mining level"));
}
}
Thanks!