Hello. Unreal Engine supports UPROPERTY meta series defines like “UPROPERTY(EditAnywhere, meta = (ClampMin = “-1.0”, ClampMax = “-100”, UIMin = “-1.0”, UIMax = “-100”))
float valueX;”.
On C++ my question is How to figure out that the Value of defined “ClampMin” of valueX.
Any hints are welcome, Thanks.
- Access the UClass via YourObject->GetClass() or YourClass::StaticClass()
- Access the FProperty via UClass->FindPropertyByName(“PropName”)
- Access metadata via FProperty->GetMetaData
UClass* Class = AMyActor::StaticClass();
if (auto Prop = Class->FindPropertyByName("MyProp"))
{
FString sClampMax = Prop->GetMetaData("ClampMax");
float ClampMax;
LexFromString(ClampMax, *sClampMax);
UE_LOG(LogTemp, Log, TEXT("ClampMax: %f"), ClampMax);
}
Note that metadata is only available in editor builds, as it is stripped from shipping builds.
2 Likes
Thanks million. Very helpful to me.