When editor crashed after called function the debuger make exception and show me this string
UE_CLOG(!GIsInConstructor, LogUObjectGlobals, Fatal, TEXT(“FObjectFinders can’t be used outside of constructors to find %s”), ObjectToFind);
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyRunner.h"
#include "GeneratorFunctionLibrary.h"
//Happy Message
FString UGeneratorFunctionLibrary::GetHappyMessage()
{
static ConstructorHelpers::FObjectFinder<UDataTable> GameObjectLookupDataTable_BP(TEXT("DataTable'/Game/ThirdPerson/GameObjectLookupTable.GameObjectLookupTable'"));
return FString("Victory! Victory BP Library Works!");
}
I tried add _C to the end of path but it’s doesn’t help.
Then please go to the Editor, right-click on the asset in the Content tab and select “Copy Reference”.
Paste the code as function parameter and that’s it:
I concur with 's answer but I would like to add that I have reproduced the crash that you experienced and, even if your implementation is wrong, the editor should avoid crashing in this situation. I’ve reported the crash and for your reference the bug number is UE-15816.
#pragma once
#include "StrucGenerator.generated.h"
FORCEINLINE UDataTable* LoadObjFromPath(const FName& Path)
{
if (Path == NAME_None) return NULL;
return Cast<UDataTable>(StaticLoadObject(UDataTable::StaticClass(), NULL, *Path.ToString()));
}
/** Structure to store the lookup of GameObjects for use in a UDataTable */
USTRUCT(Blueprintable)
struct FStrucGenerator : public FTableRowBase
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GO")
UDataTable* TestDataTable;
FStrucGenerator()
{
UDataTable* TestDataTable = LoadObjFromPath<UDataTable>(TEXT("DataTable'/Game/ThirdPerson/TableLocalGenerator.TableLocalGenerator'"));
Option = 1;
Position.Set(0, 0);
}
};
1>c:\users\documents\unreal projects\myrunner\source\myrunner\StrucGenerator.h(41): error C2275: ‘UDataTable’ : illegal use of this type as an expression
1> C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Engine/DataTable.h(28) : see declaration of ‘UDataTable’
1>C:\Users\Documents\Unreal Projects\MyRunner\Source\MyRunner\StrucGenerator.h(41): error C2275: ‘UDataTable’ : illegal use of this type as an expression
1> C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Engine/DataTable.h(28) : see declaration of ‘UDataTable’