How to avoid invoking property update callback function when a property is changed in the editor until the slider is released

I have a class UMyClass derived from UObject, and a property inside this class, e.g.

class ENGINE_API UMyClass : public UObject
{
public:
    UPROPERTY(EditAnywhere, Category = Parameters)
	float Property;
    ...
}

Plus, the function that uses these properties is included in

void UStaticMesh::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
   ...
   Function(Property);
   ...
}

By default, Function(Property) will be called lots of times using UE4 slider to tweak Property. However, Function() in our case is quite expensive, so we want to avoid calling it several times. Instead, we would like to avoid calling Function(Property) until the slider is released.

Is there a flag for UPROPERTY to do this? Or any other solutions?

Thanks.

Cheers,

I would guess you would need to only update it when OnControllerCaptureEnd or OnMouseCaptureEnd is triggered :

Thanks for the links.

I was thinking maybe there is an option in UPROPERTY flags/meta data that can be used to indicate this kind of usage. But it turned out there is no such flag. As for OnMouseCaptureEnd, I don’t see any function calls regarding to it in my case.

Any more details or suggestions?

I see 3 solutions for you :

  1. Go through the user widget tree to find your USlider widget and then use USlider->OnMouseCaptureEnd.AddDynamic(this, &MyListenerClass::OnMouseCaptureEndHandler);
    A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums

  2. It would be better to first create/spawn the USlider widget from your c++ class with MySlider = CreateWidget<USlider>(MyPlayerController, ParentWidget); and then simply use the solution in 1 USlider->OnMouseCaptureEnd.AddDynamic(this, &MyListenerClass::OnMouseCaptureEndHandler);
    https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Blueprint/CreateWidget/1/

  1. If you want total control over this slider you can inherit it.
    Look at the class USlider | Unreal Engine Documentation
    And you can then just expose the event to blueprint and do even more :slight_smile: