In 4.15 I had this code (which worked) in a utility class (cpp):
template <typename Type>
static Type* ULib::CreateObject(FString Path)
{
Type* Temp = nullptr;
Temp = ConstructorHelpers::FObjectFinderOptional<Type>(*Path).Get();
#if WITH_EDITOR
if (Temp == nullptr) { UE_LOG(LogTemp, Error, TEXT("%s"), *Path) }
#endif
return Temp;
}
And this in a character class (cpp) in the constructor:
MeshComp->SetSkeletalMesh(ULib::CreateObject<USkeletalMesh>("/Game/AnimationAssets/UE4_Mannequin/Mesh/SK_Mannequin"));
MeshComp->SetMaterial(0, ULib::CreateObject<UMaterialInterface>("/Game/AnimationAssets/UE4_Mannequin/Materials/M_UE4Man_Body"));
MeshComp->SetMaterial(1, ULib::CreateObject<UMaterialInterface>("/Game/AnimationAssets/UE4_Mannequin/Materials/M_UE4Man_ChestLogo"));
MeshComp->SetRelativeLocation(FVector(0.0f, -10.0f, -90.0f));
MeshComp->SetRelativeRotation(FRotator(0.0f, -90.0f, 0.0f)); // Face the X-axis.
But now in 4.18 it no longer works. This is my build file line:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "AIModule", "UMG", "Slate", "SlateCore", "RHI" });
Error:
fatal error LNK1120: 2 unresolved externals
Where/What is the problem?