[BUG?] Editor crash on loading ConstructorHelpers::FObjectFinder<UDataTable> is in BluePrintLibrary

I have an editor crash on loading.
It is cause when I add


ConstructorHelpers::FObjectFinder<UDataTable> GameObjectLookupDataTable_BP(TEXT("DataTable'/Game/ThirdPerson/GameObjectLookupTable.GameObjectLookupTable'"));

to my UGeneratorFunctionLibrary.

untiteled.png

No minidump found for this crash.
.H



#pragma once

#include "Kismet/BlueprintFunctionLibrary.h"
#include "GeneratorFunctionLibrary.generated.h"

UCLASS()
class MYRUNNER_API UGeneratorFunctionLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:
	UFUNCTION(BlueprintCallable, Category = "VictoryBPLibrary")
		static FString GetHappyMessage();	
};


.CPP



#include "MyRunner.h"
#include "GeneratorFunctionLibrary.h"

ConstructorHelpers::FObjectFinder<UDataTable> GameObjectLookupDataTable_BP(TEXT("DataTable'/Game/ThirdPerson/GameObjectLookupTable.GameObjectLookupTable'"));

//Happy Message
FString UGeneratorFunctionLibrary::GetHappyMessage()
{
	return FString("Victory! Victory BP Library Works!");
}



If I move this string to GetHappyMessage() then Editor will have loaded but when I start game it will crash (because the function called on event begin play)

The path in ConstructorHelpers is true because I copy it from editor (RightClick on it → CopyReference)

The GameObjectLookupDataTable is created from class StrucGenerator in Editor and it is normal, i can edit it and save, is is ok.

.H



#pragma once

#include "StrucGenerator.generated.h"

USTRUCT(Blueprintable)
struct FStrucGenerator : public FTableRowBase
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GO")
		int32 Rank;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GO")
		int16 Category;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GO")
		int32 Usecode;

	FStrucGenerator()
	{

	}
};

ConstructorHelpers functions need to be declared within the class’ constructor. The constructor will probably have a name resembling:

UGeneratorFunctionLibrary::UGeneratorFunctionLibrary(…)
{

}

I can’t override UGeneratorFunctionLibrary and UBlueprintFunctionLibrary constructor :frowning:

I’ve found that certain paths from the editor need modified to work properly with the ObjectFinder()

change


ConstructorHelpers::FObjectFinder<UDataTable> GameObjectLookupDataTable_BP(TEXT**("DataTable'/Game/ThirdPerson/GameObjectLookupTable.GameObjectLookupTable'"))**;

to


ConstructorHelpers::FObjectFinder<UDataTable> GameObjectLookupDataTable_BP**(TEXT("/Game/ThirdPerson/GameObjectLookupTable.GameObjectLookupTable"))**;

and see if that fixes it.

You’re removing the DataType from the beginning of the path, and you’re getting rid of the apostrophe (’ ') markings.

If that doesn’t work, try:


ConstructorHelpers::FObjectFinder<UDataTable> GameObjectLookupDataTable_BP**(TEXT("/Game/ThirdPerson/GameObjectLookupTable"))**;

which removes the additional “.GameObjectLookupTable” at the end of the pathfile, it was the only way to get my UMG Blueprint Class referenced in C++.