Now that I have managed to get a [custom datatable declared and imported][1] I have stumbled on a new problem.
You will notice that the link between “OutRow” on the GetDataTableRow Node is not linked to the BreakCrdDetail node. As far as I can tell this is because I have selected the DataTable from among my assets rather than via a variable. Although I can drag and connect this link and compile the game successfully, each time I open the editor the link is broken. If I try to run the game as a standalone it first recompiles the project, which means it breaks the link and then tries to compile it with the link broken, and then gives an error that it couldn’t compile the blueprint due to the missing link!
I had a very similar problem with [SpawnActorFromClass][3] where the output node changed to a default “Actor” each time rather than mirroring the input class, which caused the blueprint compile to fail each time for the same reason because the following node expected input of an actor subclass. In that project I could use a workaround to cast the output object to the specific class I wanted, but I can’t do that in this instance as there is no node to take the default “TableRowBase” object and convert it to “CrdDetail”.
I have tried this by just using the .h file only, as per the sample docs, and while I do indeed get the structure defined and I can import a .csv successfully, the link in the blueprint still breaks - the problem is with the node not with the UStruct.
So, I tried a new angle, suspecting the problem could be resolved by extending from the correct class (DataTable) rather than a generic UObject. I used “Add code to class”, expanded the dialog to expose all classes, and extended from DataTable. I stuck in the custom definitions from the original .h file, and tried to compile. It failed giving 3 “LNK2001: unresolved external reference” errors for UDataTable::FinishDestroy(void), UDataTable::Serialize(class FArchive &), and UDataTable::AddReferencedObjects(class UObject *,class FReferenceCollector &). From my reading on the topic of linker errors it would appear these functions are not publicly exposed by the engine and it requires a fix from the dev team, but I could be wrong. I added a #include “Card_Detail.generated.inl” reference in the .cpp, but got an error saying .inl files had been deprecated, so I removed it.
I understand that I could write my own overrides for these functions, but I wouldn’t want to create empty functions as there is no guarantee that I’d not be making the problem worse. I’d like to copy the source code, but I’m a bit lost at this point as to where it is as my primitive searching through the Unreal Engine/4.4 folder does not turn up any hits for “data” or “table”.
Can anyone point me in the right direction, or help me fix the issue with the blueprint link disappearing each time?
I wasn’t really sure whether to put this in the C++ or blueprint sections, as it impacts both, but the behaviour of the LNK2001 errors leads me to believe it’s a bug.
Here is the code (the project is called “Blank” because I’m just testing things, there is no map level or much of anything):
Card_Detail.h
#pragma once
#include "Card_Detail.generated.h"
USTRUCT(BlueprintType)
struct FCrdDetail : public FTableRowBase
{
GENERATED_USTRUCT_BODY()
public:
FCrdDetail()
: CName("")
/** other definitions cut */
{}
/** The name of the entry */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = CDet)
FString CName;
/** other definitions cut */
};
UCLASS()
class BLANK_API UCard_Detail : public UDataTable
{
GENERATED_UCLASS_BODY()
};
Card_Detail.cpp
#include "Blank.h"
#include "Card_Detail.h"
UCard_Detail::UCard_Detail(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
}