UDatatable Loading outside Constructor (Dynamically)

Hey all,

I’m trying to set up a dynamic calling for UDatatables. My system setup is the following: there is user input which determines a set of profiles. Depending on the profile output, the player will load a UDataTable (Final Directory is selected on runtime).

I want to load the UDataTable outside the Constructor. I know that the Constructor method is:

	const TCHAR* TempChar = *DataTableReference;
	static ConstructorHelpers::FObjectFinder<UDataTable> temp(TempChar);
	UDataTable* DataTable = temp.Object;
	FString Context; //
	if (DataTable != nullptr)
	{
		TArray<FName> Names = DataTable->GetRowNames();
		for (int X = 0; X < Names.Num(); X++)
		{
			//Do something. Find Row Function -> * (DataTable->FindRow<FStructure> (Names[X], Context, true))

		}
	}

Based on Googling, I found that one can load things with UObjectLibrary

However, I don’t seem to understand how to do it this way.

I also looked into this one:

But don’t know how to transform the FString to the structure that I’m after.

I dove into trying to understand it this way too:

but nothing is working so far.

How does one approach this? Thank you in advance.

Feeling kind of dumb for having missed it but I had totally forgotten about Load Object.

This Worked:

   UDataTable* DataTable = LoadObject<UDataTable>(NULL, *DataTableReference, NULL, LOAD_None, NULL);
	if (!DataTable) return;
	FString Context; //
	TArray<FName> Names = DataTable->GetRowNames();
    if (!Names.Num()) return;
	for (int X = 0; X < Names.Num(); X++)
	{
		//Do something. Find Row Function -> * (DataTable->FindRow<FStructure> (Names[X], Context, true))
	}

Leaving this for reference if anyone ever needs it.

1 Like