← All namespaces

ui

UI & widgets Core

Drive live widget instances during play: instantiate, mutate state, and remove.

What it's for

ui operates on live UMG widgets during a Play-In-Editor session. You use it to instantiate a widget blueprint into the player viewport, change what it shows at runtime — text, images, visibility — and then tear it back down. Nothing here touches disk: the changes exist only in the running PIE instance and are gone once play stops.

Reach for it when you want to see a widget behaving in a real viewport, drive a HUD through some states to check it looks right, or push and pop screens on an activatable stack the way the game does at runtime. Because everything runs against a live session, you start PIE first — there is no viewport to add to in plain editor mode.

This is the runtime counterpart to widget, which authors the underlying UWidgetBlueprint asset on disk. Pick the namespace by which side you want to persist: widget edits survive an editor restart, ui edits vanish when PIE ends. For asset-side property changes, mutate the widget blueprint's CDO with property.set instead.

A few ui methods (play, stop, save, screenshot, input) are near-duplicates of their editor equivalents, kept only for symmetry within the namespace. Prefer the canonical editor forms; the runtime widget operations below are what this namespace is really for.

Examples

Instantiate a HUD and set its readout

Start play, add the widget blueprint to the viewport, then write into one of its text blocks by slot name.

You: Play the level, add WBP_HUD to the viewport, and set its Score text to 1200.

  call("editor.play", {})
    → {ok:true, playing:true}
  call("ui.create_hud", {widgetPath:"/Game/UI/WBP_HUD"})
    → {ok:true, widget:"WBP_HUD"}
  call("ui.set_widget_text", {key:"Score", value:"1200"})
    → {ok:true}

Done. WBP_HUD is live in the viewport with Score reading 1200.

Hide a widget, then swap an image

Mutate the live instance: collapse one element and repoint an image brush at another texture.

You: In the running HUD, hide the WarningLabel and change the StatusIcon to the green one.

  call("ui.set_widget_visibility", {key:"WarningLabel", visible:false})
    → {ok:true}
  call("ui.set_widget_image", {key:"StatusIcon", texturePath:"/Game/UI/T_Status_Green"})
    → {ok:true}

Done. WarningLabel hidden and StatusIcon now shows the green texture.

Remove the widget when you're finished

Take the instance back out of the viewport, undoing the earlier ui.create_hud without touching the asset.

You: Remove that HUD from the viewport.

  call("ui.remove_widget_from_viewport", {key:"WBP_HUD"})
    → {ok:true}

Done. WBP_HUD removed from the viewport; the widget blueprint asset is untouched.

← Back to all namespaces