ue-ui-umg-slate

Use this skill when working with UMG, UI, widget, UserWidget, Slate, HUD, BindWidget, Common UI, menu, or UMG binding in Unreal Engine. See references/widget-types.md for widget type reference and references/common-ui-setup.md for Common UI plugin setup. For Slate in editor tools, see ue-editor-tool

By quodsoler · 967 installs

npx skills add quodsoler/unreal-engine-skills --skill ue-ui-umg-slate

Source repository · Upstream listing

UE UI: UMG, Slate, and Common UI Target engine: UE 5.8 . APIs below are verified against the 5.8 headers; older forms are listed under "Deprecated — do not use". UMG is the runtime UI framework ( UMG module, Engine/Source/Runtime/UMG/Public ) built on Slate ( Slate , SlateCore ). Common UI (plugin, production in 5.8) adds cross platform input routing, activation stacks and platform aware buttons. Model View Viewmodel (plugin, Beta in 5.8) adds declarative data binding on top of FieldNotification . Context Read .agents/ue project context.md if it exists (module names, conventions, enabled plugins, GAS/networking setup). Do not stop if it is missing. Identify the area from the request and the codebase. Ask only when two plausible readings would produce different code. Request is about… Go to Widget class, overrides, creation, visibility, GC [Widget Lifecycle]( widget lifecycle) Wiring designer widgets into C++ ( meta=(BindWidget) ) [BindWidget]( bindwidget) Buttons, text, images, bars, lists [Widget Interaction]( widget interaction) Playing/stopping UMG animations [Widget Animation]( widget animation) Mouse cursor, focus, SetInputMode [Input Mode and Focus]( input mode and focus) Menus, screen stacks, gamepad, back action [Common UI]( common ui) Data binding, view models, field notifications [MVVM]( mvvm) UI rendered in the level [World Space UI]( world space ui) Iterating widgets, drag/drop, brushes, geometry [Widget Tree and Helper Libraries]( widget tree and helper libraries) Custom SWidget , SNew , SLATE BEGIN ARGS [Slate]( slate) Per widget method tables (setters, delegates, enums) live in [references/widget types.md](references/widget types.md). Full Common UI plugin setup lives in [references/common ui setup.md](references/common ui setup.md). A complete custom Slate widget lives in [references/slate patterns.md](references/slate patterns.md). Widget Lifecycle Override (verbatim from Blueprint/UserWidget.h ) When it runs virtual void NativeOnInitialized() override; Once per instance, after construction of the widget object virtual void NativePreConstruct() override; After the Slate tree is rebuilt, just before NativeConstruct ( UserWidget.cpp:1231 ); also runs in the Designer virtual void NativeConstruct() override; Slate widget added to a parent — bind delegates here virtual void NativeDestruct() override; Slate widget removed — unbind here virtual void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override; Per frame while ticking virtual int32 NativePaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override; Custom drawing; return the last used layer id virtual FReply NativeOnMouseButtonDown(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent) override; Pointer press virtual FReply NativeOnKeyDown(const FGeometry& InGeometry, const FKeyEvent& InKeyEvent) override; Key press while focused virtual FReply NativeOnFocusReceived(const FGeometry& InGeometry, const FFocusEvent& InFocusEvent) override; This widget gained focus virtual void NativeOnAddedToFocusPath(const FFocusEvent& InFocusEvent) override; This widget or a descendant gained focus virtual bool Initialize() override; Builds the widget tree; call Super::Initialize() and return its result virtual TSharedRef<SWidget RebuildWidget() override; Builds the underlying Slate widget virtual void ReleaseSlateResources(bool bReleaseChildren) override; Drop cached TSharedPtr<SWidget members here Input handlers return FReply::Handled() to consume the event or FReply::Unhandled() to let it bubble. Creation, viewport, visibility HitTestInvisible draws but passes input through for the widget and its children; SelfHitTestInvisible passes input through for the widget only. Hold a UPROPERTY() TObjectPtr<UMyWidget if the widget must survive RemoveFromParent . GetOwningPlayer() returns the owning APlayerController ; GetOwningPlayer<AMyPlayerController () casts for you. BindWidget Rules: the C++ member name must match the Widget Blueprint's widget name exactly (case sensitive); the declared type must match or be a base of the designer widget's class; bound members are assigned inside Initialize() before NativeOnInitialized runs ( UserWidget.cpp:153,175 ), so they are valid in NativeOnInitialized , NativePreConstruct and NativeConstruct — bind once per instance delegates in NativeOnInitialized . Declare them protected with no Category . Widget Interaction Dynamic multicast delegates on UMG components use AddDynamic , so the handler must be a UFUNCTION() . Method and enum tables for UButton , UTextBlock , UImage , UProgressBar , UScrollBox , UWidgetSwitcher , UCheckBox , UEditableTextBox , USlider , UComboBoxString and the UWidget base are in [references/widget types.md](references/widget types.md). Lists: UListView, UTileView, UTreeView All three are virtualised — only visible entry widgets exist, and they are recycled. Items are UObject ; the entry widget derives from UUserWidget and implements IUserObjectListEntry , overriding virtual void NativeOnListItemObjectSet(UObject ListItemObject) override; (call IUserObjectListEntry::NativeOnListItemObjectSet first). The full entry widget example and the UListView method table are in [references/widget types.md](references/widget types.md). BP OnItemClicked is a Blueprint only private delegate. From C++, bind the native event ItemList OnItemClicked().AddUObject(...) ( FSimpleListItemEvent , Components/ListViewBase.h:48 ; also OnItemSelectionChanged() ), or override virtual void OnItemClickedInternal(UObject Item) override; in a UListView subclass. Inside an entry widget, read the item with GetListItem<UMyItemData () and query selection with the interface member IsListItemSelected() ( Blueprint/IUserListEntry.h:32 ). Widget Animation PlayAnimation and its variants return an FWidgetAnimationHandle ( Animation/WidgetAnimationHandle.h ); keep the handle, not a sequence player pointer. A valid handle may still resolve to no state once the animation finishes, so check IsValid() . Input Mode and Focus ue input system owns input modes and Enhanced Input. Minimal correct form: FInputModeGameAndUI also has SetWidgetToFocus and SetLockMouseToViewportBehavior . Set the input mode from the code that added the widget (HUD, PlayerController, GameMode), not from NativeConstruct . When Common UI is enabled, do not call SetInputMode at all — return an FUIInputConfig instead. Common UI Enable the CommonUI plugin (it ships both the CommonUI and CommonInput modules), add both modules to Build.cs, and set the viewport client class to UCommonGameViewportClient — it reroutes input to the UI action router before the game ( CommonGameViewportClient.h:21 ); gamepad/mouse/touch changes are detected by UCommonInputSubsystem 's FCommonInputPreprocessor and broadcast from that subsystem. Setup details, layer architecture and settings keys are in [references/common ui setup.md](references/common ui setup.md). Public API: ActivateWidget() , DeactivateWidget() , IsActivated() , GetDesiredFocusTarget() , ClearFocusRestorationTarget() , RequestRefreshFocus() , plus the non dynamic OnActivated() / OnDeactivated() delegates. BP GetDesiredFocusTarget is the BlueprintImplementableEvent that NativeGetDesiredFocusTarget routes to — override the native one in C++. Editable defaults: bAutoActivate , bIsBackHandler , bIsBackActionDisplayedInActionBar , bIsModal , bAutoRestoreFocus , bSetVisibilityOnActivated / ActivatedVisibility , bSetVisibilityOnDeactivated / DeactivatedVisibility . ECommonInputMode is Menu (UI only), Game (game only) or All . Containers UCommonActivatableWidgetContainerBase ( Widgets/CommonActivatableWidgetContainer.h ) is the base; UCommonActivatableWidgetStack shows the topmost widget and re activates the one beneath when it deactivates; UCommonActivatableWidgetQueue shows one at a time and advances when the active one deactivates. UCommonActivatableWidgetSwitcher is an index based switcher, not a stack — do not use it here. Buttons, input type, action routing OnInputMethodChangedNative is a DECLARE EVENT OneParam , so HandleInputMethodChanged(ECommonInputType) needs no UFUNCTION() . Enhanced Input and Common Input are unified in 5.8: with bEnableEnhancedInputSupport on ( UCommonInputSettings::IsEnhancedInputSupportEnabled() ), FBindUIActionArgs takes a const UInputAction and UCommonActivatableWidget::InputMapping / InputMappingPriority push a mapping context on activation. MVVM ModelViewViewModel is Beta in 5.8. A view model is a UMVVMViewModelBase ; FieldNotify properties get a generated field descriptor, and UE MVVM SET PROPERTY VALUE compares, assigns and broadcasts in one call. UE MVVM SET PROPERTY VALUE(MemberName, NewValue) expands to SetPropertyValue(MemberName, NewValue, ThisClass::FFieldNotificationClassDescriptor::MemberName) . Use UE MVVM SET PROPERTY VALUE INLINE for values that cannot be passed as function arguments (bitfields), and UE MVVM BROADCAST FIELD VALUE CHANGED(MemberName) when you assigned the member yourself; both end in BroadcastFieldValueChanged(UE::FieldNotification::FFieldId) from INotifyFieldValueChanged . UHT generates the descriptor for every FieldNotify property and function. Declare fields by hand only under the UCLASS(CustomFieldNotify) class specifier (not a meta key; see Components/Widget.h:215 ), with the UE FIELD NOTIFICATION DECLARE CLASS DESCRIPTOR BEGIN / UE FIELD NOTIFICATION DECLARE FIELD(Name, API STRING) / UE FIELD NOTIFICATION DECLARE ENUM FIELD(Name) / ... END family in FieldNotificationDeclaration.h ( FieldNotification module; the old FieldNotification/ path is deprecated since 5.3), paired with UE FIELD NOTIFICATION IMPLEMENTATION BEGIN and UE FIELD NOTIFICATION IMPLEMENTATION END in the .cpp. UMVVMView also exposes GetViewModel(FName) , SetViewModelByClass(...) and ExecuteViewModelBindings(FName) ; UMVVMSubsystem is a UEngineSubsystem and GetViewFromUserWidget is static. World Space UI UWidgetComponent ( Components/WidgetComponent.h , UMG module) renders a UUserWidget onto a plane or cylinder in the level. Enable bReceiveHardwareInput only for a widget that must take real mouse input; otherwise drive interaction with a UWidgetInteractionComponent . Widget Tree and Helper Libraries UWidgetBlueprintLibrary ( Blueprint/WidgetBlueprintLibrary.h ) holds the brush, drag and drop, FEventReply and FPaintContext drawing helpers; USlateBlueprintLibrary ( Blueprint/SlateBlueprintLibrary.h ) converts between local, absolute and viewport space. Both are enumerated in [references/widget types.md](references/widget types.md). Slate Use Slate for editor extensions and for runtime widgets UMG does not expose. SWidget is the base; SCompoundWidget is the usual parent for a custom widget. A custom widget declares its arguments between SLATE BEGIN ARGS / SLATE END ARGS — SLATE ATTRIBUTE for a TAttribute<T that can be bound to a lambda, SLATE ARGUMENT for a plain value, SLATE EVENT for a delegate — and builds its children into ChildSlot inside Construct(const FArguments& InArgs) . Bind Slate delegates with CreateSP so a destroyed widget never gets called. A complete SCompoundWidget with all three argument kinds: [references/slate patterns.md](references/slate patterns.md). SNew(WidgetType) returns a TSharedRef<WidgetType ; SAssignNew(Var,