Navigation
API > API/Editor > API/Editor/UMGEditor > API/Editor/UMGEditor/FWidgetBlueprintOperationUtils
Description
Replaces a widget instance in the blueprint's widget tree with a new instance created from a different template widget class. Performs hard validations (params, widget identity in the tree, circular blueprint reference, BindWidget contract on the parent class chain, panel rules and child-capacity for panel-to-panel swaps) and aborts without mutating on failure. On success, references to compatible members on the new class are retargeted; references to members that don't exist on the new class are left pointing at the old class so the user sees them as orphaned in the graph.
Panel handling: if WidgetToReplace is a panel with children, TemplateClass must also be a panel widget that can hold every existing child. Slot properties are preserved across the move where the new slot accepts them.
| Name | ReplaceWidgetWithTemplate |
| Type | function |
| Header File | /Engine/Source/Editor/UMGEditor/Public/WidgetBlueprintOperationUtils.h |
| Include Path | #include "WidgetBlueprintOperationUtils.h" |
| Source | /Engine/Source/Editor/UMGEditor/Private/WidgetBlueprintOperationUtils.cpp |
static bool ReplaceWidgetWithTemplate
(
UWidgetBlueprint * WidgetBlueprint,
UWidget * WidgetToReplace,
TSubclassOf < UWidget > TemplateClass,
FText & OutErrorMessage
)
true on success, false on hard failure (no side effects on failure).
Parameters
| Name | Remarks |
|---|---|
| WidgetBlueprint | The widget blueprint containing the widget to replace. |
| WidgetToReplace | The widget instance to replace (must be in WidgetBlueprint's tree). |
| TemplateClass | The widget class to create the replacement from. |
| OutErrorMessage | Filled on failure with a description of what went wrong. |