UE4 supports binding property values with delegates. For example, this is how Brush
property is declared in UImage
:
/** Image to draw */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Appearance)
FSlateBrush Brush;
/** A bindable delegate for the Image. */
UPROPERTY()
FGetSlateBrush BrushDelegate;
When the same is declared inside USTRUCT
that is used as an element of TArray
, there is no Bind
dropdown in the Editor. Sample, to demonstrate the idea:
#include "Engine.h"
#include "UMG.h"
#include "MyButton.generated.h"
USTRUCT()
struct FBindableBrush {
GENERATED_USTRUCT_BODY()
public:
/** Image to draw */
UPROPERTY(EditAnywhere)
FSlateBrush Brush;
/** A bindable delegate for the Image. */
UPROPERTY()
UWidget::FGetSlateBrush BrushDelegate;
};
UCLASS()
class UMyButton: public UButton {
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Brushes")
TArray<FBindableBrush> Brushes;
};
Steps to reproduce:
- Add “Slate”, “SlateCore”, “UMG” as dependencies in Build.cs file of your project.
- Create “MyButton.h” in your project, copy-paste the sample above into it.
- Create “MyButton.cpp” that merely contains include of your project header and MyButton.h.
- Compile the project.
- Create a Widget Blueprint in the Editor.
- Drop “My Button” from “Common” section of the Palette.
- In the Properties window of the button, add an element to “Brushes” array.
- Observe that there is no “Bind” dropdown for the newly added element of the array. But if you put the same properties directly into a Widget (like UMG does in many places), then the “Bind” dropdown appears.