UMG: Previewing custom blueprint Widgets in realtime

One of benefits of C++ widgets is that they allow you to see realtime preview in the editor, when changing their properties.

Custom blueprint user widgets do not allow this, as the blueprint scripts aren’t being run while editing properties in the editor. This tutorial adds a *OnSynchronizeProperties *blueprint event, which will be called every time you edit a property in editor.

This enables realtime preview of blueprint widgets.

NOTE: This is an experimental feature. Backup your project first.

Example:
Here is a popup window containing multiple generic custom list widgets. Each custom list generates a title text and list of buttons. The custom list widgets have custom default properties for the list title string and an array of button title strings.

Without the realtime view, only manually added placeholder values are displayed. With realtime preview, the custom list widgets construct and configure all the neccessary widgets.

Wiki: https://wiki.unrealengine.com/UMG_Previewing_custom_UserWidgets_in_realtime

Interesting, meanwhile i will subscribe the thread :slight_smile:

Reviving this post as it is very interesting and a long-overdue feature.

Few questions:

  • Has this become obsolete due to event “Pre Construct”?
  • I have multiple nested widgets (Widget1 creates child widgets, each child widget contains a text and a varying number of buttons that get created as well), will these events all run when previewing the main widget? I.e. will it trigger “On Initialize” or “On Synchronize Properties” in widgets that get created in another “On Synchronize Properties” event chains?
  • I am really not good at plain, “real” coding. I know how to create a new C++ class as described in your wiki post (Step 1), but I don’t know what I should be doing for Step 2 (“Overwrite SynchronizeProperties() and call the OnSynchronizeProperties() event”). Its the same class, so should the body of code go into the newly created class as well or do I have to overwrite something in the Engine files?
Should I copy this code into the newly created class?

class MYPROJECT_API UDesignableUserWidget : public UUserWidget
{
GENERATED_BODY()
public:
/**
* This is called after a widget is constructed and properties are synchronized.
* It can also be called by the editor to update modified state.
* Override this event in blueprint to update the widget after a default property is modified.
*/
UFUNCTION(BlueprintNativeEvent, Category = “User Interface”)
void OnSynchronizeProperties();
public:
virtual void SynchronizeProperties() override;
};
void UDesignableUserWidget::OnSynchronizeProperties_Implementation()
{
// Override this event in Blueprint
};
void UDesignableUserWidget::SynchronizeProperties() {
Super::SynchronizeProperties();
OnSynchronizeProperties();
}

EDIT: Of course with the proper indents that got cut-off here…

If you or someone else finds the time to ellaborate on this a little bit, I would be very thankful!