// UReflectionUtiFB.cpp
template <typename InStructType>
float UReflectionUtiFB::GetFloatValueByFiledName(const InStructType& InStruct, const FName& FiledName)
{
// UE_LOG(LogTemp, Warning,TEXT("FileName: %s"), *FiledName);
const UScriptStruct* StructDefinition = InStructType::StaticStruct();
FProperty* Property = StructDefinition->FindPropertyByName(FiledName);
const float* Val = Property->ContainerPtrToValuePtr<float>(&InStruct);
return *Val;
}
// BaseNPC.cpp
void UBaseNPC::CheckEvent()
{
FNPCInfo NInfo;
Info.Name = FText::FromString("Abc");
float NPCVal = UReflectionUtiFB::GetFloatValueByFiledName<FNPCInfo>(NInfo, FName("FieldName"));
}
when i build, I got an error:
Error LNK2019 unresolved external symbol "public: static float __cdecl UReflectionUtiFB::GetFloatValueByFiledName<struct FNPCInfo>(struct FNPCInfo const &,class FName const &)" (??$GetFloatValueByFiledName@UFNPCInfo@@@UReflectionUtiFB@@SAMAEBUFNPCInfo@@AEBVFName@@@Z) referenced in function "private: void __cdecl UBaseNPC::CheckEvent(void)" (?CheckEvent@UBaseNPC@@AEAAXXZ)
How should I use it?
help me , thank you.