Download

How property binding is working?

I mean how can I create my own property binding system in my custom blueprint? I want to bind a property value to function, in that function I can use other properties of blueprint. So when some property chanched all dependent properties will change too. I know that it realised in UMG and I can get sourse code… but may be some advices?

Recent engine versions allows to do things like this:



private:

UPROPERTY(EditAnywhere, BlueprintSetter = SetHealth, BlueprintGetter = GetHealth)

float Health;


public:

UFUNCTION(BlueprintSetter)
void SetHealth(float NewHealth);

UFUNCTION(BlueprintGetter)
float GetHealth();


That will expose your custom function as a replacement to those “GET” or “SET” little nodes you see on Blueprint Graphs.

It’s not what I want :slight_smile:
In UMG we can bind text on text widget, e.g. bind text to player health. If player health change then text on text widget will automatically change too. So I want to create this binding

I think what you want to look at is the PROPERTY_BINDING_IMPLEMENTATION macro. Look at TextBlock.cpp/h and see how the binding is setup. I never done it myself but it looks fairly simple.