Post Edit Change Property 从子类修改父类的变量属性(UPROPERTY)
发表于2019-12-11
例如,限制输入框的最小值
.h
UCLASS()
class MYPILOTPROJECT_API UMyScrollBox : public UScrollBox
{
GENERATED_BODY()
public:
UMyScrollBox();
//***重写PostEditChangeProperty,可以修改父类的变量的UPEOPERTY属性****
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)override;
};
_________________________________________________________
.cpp
void UMyScrollBox::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
ScrollbarThickness = FVector2D
(
UKismetMathLibrary::Clamp(ScrollbarThickness.X, 2.0f, INT32_MAX),
UKismetMathLibrary::Clamp(ScrollbarThickness.X, 2.0f, INT32_MAX)
);
}