The comment describing UClass::HasProperty() indicates that it checks to see if a specified property exists in a class, or a parent of that class. However, when a property that exists in a child of that class is passed in, HasProperty() still returns true.
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = TestCat) USceneComponent* MyComp;
MyComp = CreateDefaultSubobject<USceneComponent>(TEXT("MyComp")); UProperty* prop = this->StaticClass()->FindPropertyByName("MyComp"); if (prop) { bool bResult = AActor::StaticClass()->HasProperty(prop); if (GEngine) { if (bResult) { GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::MakeRandomColor(), TEXT("AActor has MyComp.")); } else { GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::MakeRandomColor(), TEXT("AActor does not have MyComp.")); } } }
RESULT:
A message is displayed on the screen indicating that AActor contains MyComp.
EXPECTED:
A message is displayed on the screen indicating that AActor does not contain MyComp.
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-67859 in the post.
1 |
Component | UE - Foundation - Core |
---|---|
Affects Versions | 4.21.1, 4.22, 4.20.3 |
Target Fix | 4.22 |
Created | Dec 21, 2018 |
---|---|
Resolved | Jan 8, 2019 |
Updated | Feb 12, 2019 |