Fairly simple question, but I can’t tell if I’m just not finding documentation or if I shouldn’t be trying to do this in the first place.
In my C++ UDataAsset, I have the uproperty:
int32 NumPages = 100;
I want to make sure the input for this data asset is always positive using a MakePositive function (which is already written.)
But… how do I do that? Is it even a good idea to do that or is this not how a data asset is intended to work?
Extrone
(Arjun Subhash)
October 31, 2026, 5:47pm
2
If you’re trying to limit the value of NumPages to only positive values while modifying it in the edttor, you can use the meta property ClampMin to set a minimum value.
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta=(ClampMin=0))
int32 NumPages = 100;
Unreal's Property Specifiers page lists all of the core specifiers and many of the metadata specifiers, but it is not an exhaustive list. | Sample code, screenshots and comments for all specifiers, including undocumented ones.
There’s also the PostEditChangeProperty function that you can override to do operations on the value after it was edited.
#if WITH_EDITOR
void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif
#if WITH_EDITOR
void ASomeActor::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
FName PropertyName = (PropertyChangedEvent.Property != NULL) ? PropertyChangedEvent.Property->GetFName() : NAME_None;
if (PropertyName == GET_MEMBER_NAME_CHECKED(ASomeActor, NumPages))
{
if (NumPages < 0)
{
MakePositive();
}
}
}
#endif
^ modified code from:
/* If MyBool belongs to the ASomeActor */
void ASomeActor::PostEditChangeProperty(struct FPropertyChangedEvent& e)
{
Super::PostEditChangeProperty(e);
FName PropertyName = (e.Property != NULL) ? e.Property->GetFName() : NAME_None;
if (PropertyName == GET_MEMBER_NAME_CHECKED(ASomeActor, MyBool)) {
/* Because you are inside the class, you should see the value already changed */
if (MyBool) doThings(); // This is how you access MyBool.
els…