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.

It’s a long time,but I have a similar idea right now. I want to make a plugin with a actor component,that has a property can be binded with function to change its value,just work like some property in UMG. Do you have solve this problem?

I describe I have done.
I create a new actor component class,and code like this:




But,the macro in last line is error,can not be compiled.
I have include “Components/Widget.h” ,and reshape tip like this.

and annoted the macro whith error,live compile as this,
屏幕截图 2023-06-30 155244
the property and the delegate are not binded,and the delegate can not custom.

so,what can i do to fix it?