### Accessing Slate Widget Examples (Test Suite/Starship Suite) Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/ru/README.md Provides instructions on how to access the Slate Widget Examples, known as Test Suite (UE4) or Starship Suite (UE5), within the Unreal Editor. These suites offer practical demonstrations of various Slate widgets. ```unreal-engine 1. Open Unreal Editor. 2. Navigate to the appropriate menu: - UE4: Window > Developer Tools > Debug Tools - UE5: Tools > Debug > Debug Tools 3. Select 'Test Suite' or 'Starship Suite'. ``` -------------------------------- ### API: FAnalogCursor Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md An implementation example for input preprocessors, demonstrating analog cursor behavior. ```APIDOC FAnalogCursor: Documentation: https://docs.unrealengine.com/latest/INT/API/Runtime/Slate/Framework/Application/FAnalogCursor/ ``` -------------------------------- ### Unreal Engine Input Processing Flow Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Details the step-by-step execution order for input processing within Unreal Engine, starting from APlayerController::TickPlayerInput and involving UPlayerInput and various input component interactions. This outlines the lifecycle of an input event. ```APIDOC APlayerController::TickPlayerInput UPlayerInput::Tick Collects mouse over events. Collects touch over events. APlayerController::ProcessPlayerInput APlayerController::BuildInputStack: Builds the stack of input components and their processing order. UPlayerInput::ProcessInputStack: Processes the input stack. APlayerController::PreProcessInput Copies the state of non-axis key's. Iterates through input components (top to bottom): Builds keymap for input component. Tracks touch bindings and gesture bindings. Tracks axis bindings. Determines if input should be consumed. Resets each input component's axis bindings. Broadcasts Input Actions to relevant components. Broadcasts Input Axis to relevant components. APlayerController::PostProcessInput UPlayerInput::FinishProcessingPlayerInput: Saves input states and cleans up for the next frame. Clears broadcasted bindings. Resets the input stack for the next frame. APlayerController::ProcessForceFeedbackAndHaptics ``` -------------------------------- ### Construct Event in C++ UMG Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md Fires when a widget is added to the screen, potentially multiple times if removed and re-added. It's recommended to place initial setup code in 'OnInitialized' instead of this event. ```C++ virtual void UUserWidget::NativeConstruct() { // Call BP version Construct(); UpdateCanTick(); } ``` -------------------------------- ### C++ Header: SharedPointer Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md Contains Epic's shared (smart) pointer framework. It is also recommended to check SharedPointerTesting.ini for examples of shared pointer usage. ```C++ #include "SharedPointer.h" // Internals are in SharedPointerInternals.h ``` -------------------------------- ### Get Slate User from Local Player Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md Demonstrates how to retrieve a ULocalPlayer object and then use it to get the associated Slate User from FSlateApplication. This is crucial for managing user input and focus within the Slate framework. ```C++ // The way you get the local player is dependent on your own needs // This is meant to be an example, // NOT INTENDED FOR FINAL/RELEASE CODE ULocalPlayer* localPlayer = nullptr; if(UWorld* const world = GetWorld()) { if(APlayerController* const pc = world->GetFirstPlayerController()) { localPlayer = pc->GetLocalPlayer(); } } // Valid check the local player pointer if(!IsValid(localPlayer)) { // If its not valid then exit the function return; } // Make sure Slate is initialized and working properly if(FSlateApplication::IsInitialized()) { // This function will return the Slate User that this local player is tied to FSlateApplication::Get().GetUser(localPlayer->GetControllerId()); } ``` -------------------------------- ### C++ File: SharedPointer.h Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md This header file is part of Epic's Shared (Smart) Pointer Framework. It's advisable to also review SharedPointerTesting.ini for practical examples of using shared pointers. ```C++ SharedPointer.h ``` -------------------------------- ### On Animation Started Event in C++ Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md This event occurs when a widget animation begins playing. It provides the animation that started, useful for checking or referencing. ```C++ virtual void UUserWidget::OnAnimationStartedPlaying(UUMGSequencePlayer& Player) { // Call BP version OnAnimationStarted(Player.GetAnimation()); BroadcastAnimationStateChange(Player, EWidgetAnimationEvent::Started); } ``` -------------------------------- ### On Initialized Event in C++ Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md This event occurs only once at runtime when a non-template instance of the widget is created. It's used for initial setup, like binding input delegates. ```C++ virtual void UUserWidget::NativeOnInitialized() { // Bind any input delegates that may be on this widget to its owning player controller if(APlayerController* PC = GetOwningPlayer()) { UInputDelegateBinding::BindInputDelegates(GetClass(), PC->InputComponent, this); } OnInitialized(); } ``` -------------------------------- ### Get Slate User from Local Player (C++) Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Demonstrates how to retrieve a ULocalPlayer object and subsequently access the associated Slate User via the FSlateApplication. This is crucial for managing input for local players in split-screen or single-player scenarios. ```cpp ULocalPlayer* localPlayer = nullptr; if(UWorld* const world = GetWorld()) { if(APlayerController* const pc = world->GetFirstPlayerController()) { localPlayer = pc->GetLocalPlayer(); } } // Valid check the local player pointer if(!IsValid(localPlayer)) { // If its not valid then exit the function return; } // Make sure Slate is initialized and working properly if(FSlateApplication::IsInitialized()) { // This function will return the Slate User that this local player is tied to FSlateApplication::Get().GetUser(localPlayer->GetControllerId()); } ``` -------------------------------- ### OnInitialized Event in C++ UMG Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md Occurs once when a non-template instance is created at runtime. It's ideal for initial setup, such as binding input delegates to the owning player controller. ```C++ virtual void UUserWidget::NativeOnInitialized() { // Bind any input delegates that may be on this widget to its owning player controller if(APlayerController* PC = GetOwningPlayer()) { UInputDelegateBinding::BindInputDelegates(GetClass(), PC->InputComponent, this); } OnInitialized(); } ``` -------------------------------- ### Getting First Local Player Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Retrieves the first local player from the game instance. This is the default player associated with a Widget Component if no owner player is explicitly set. ```C++ if (UWorld* LocalWorld = GetWorld()) { UGameInstance* GameInstance = LocalWorld->GetGameInstance(); check(GameInstance); return GameInstance->GetFirstGamePlayer(); } ``` -------------------------------- ### IInputProcessor API Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md The base interface class for Input Pre Processors in Unreal Engine's Slate framework. Developers would inherit from this class to create custom input processing logic. An example of how to set one up can be found by looking up FAnalogCursor. ```APIDOC IInputProcessor: Inheritance: Base interface class for Input Pre Processors. Purpose: To create custom input processing logic within the Slate framework. Example: Inherit from this class, see FAnalogCursor for an example setup. Documentation Link: https://docs.unrealengine.com/latest/INT/API/Runtime/Slate/Framework/Application/IInputProcessor/ ``` -------------------------------- ### Slate Debugger Functions Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md Functions for controlling the Slate Debugger's InvalidationRoot functionality, including starting, stopping, enabling, and filtering invalidation events. These functions provide programmatic control over the debugging tools. ```APIDOC SlateDebugger.InvalidationRoot.SetInvalidateRootReasonFilter - Description: Enables/disables specific invalidation root reason filters. - Parameters: - filter: The reason filter to apply (e.g., None, ChildOrder, Root, ScreenPosition). SlateDebugger.InvalidationRoot.Start - Description: Starts the invalidation root widget debugging tool, showing when invalid roots use slow or fast paths. SlateDebugger.InvalidationRoot.Stop - Description: Stops the invalidation root widget debugging tool. SlateDebugger.InvalidationRoot.Enable - Description: Toggles (starts/stops) the invalidation root widget debugging tool to show when invalid roots use slow or fast paths. SlateDebugger.InvalidationRoot.ToggleLegend - Description: Toggles the display of the color legend. SlateDebugger.InvalidationRoot.ToggleWidgetNameList - Description: Toggles the display of the names of invalidated root widgets. ``` -------------------------------- ### Slate Debugger: Widget Update Tracking Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Provides tools to debug widget updates in Slate. Allows starting, stopping, and toggling various display options for widget update events, including filtering by update flags and widget names. ```APIDOC SlateDebugger.Update.Start - Starts the update widget debug tool to show when widgets are updated. SlateDebugger.Update.Stop - Stops the update widget debug tool. SlateDebugger.Update.Enable - Toggles (Start/Stop) the update widget debug tool to show when widgets are updated. SlateDebugger.Update.ToggleLegend - Toggles the display of the color legend in the tool. SlateDebugger.Update.ToggleWidgetNameList - Toggles the display of the names of widgets that have been updated. SlateDebugger.Update.ToggleUpdateFromPaint - Toggles the display of widgets that do not have an update flag but are updated as a side effect of another widget. SlateDebugger.Update.SetWidgetUpdateFlagsFilter - Enables/Disables specific widget update flag filters. - Filters: - None - Tick: Widget has a tick function. - ActiveTimer: Widget has an active timer that needs to update. - Repaint: Needs repaint because the widget is dirty. - VolatilePaint: Needs repaint because the widget is volatile. - Any SlateDebugger.Update.SetInvalidationRootIdFilter - Toggles to show only the widgets that are part of an invalidation root. SlateDebugger.Update.OnlyGameWindow - Toggles to only show the debug info for the game window. ``` -------------------------------- ### Slate Debugger: Invalidation Root Tracking (Console) Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Tools for debugging invalidation roots, specifically tracking whether they use the slow or fast path. Allows starting, stopping, and toggling display options like legends and widget name lists. ```APIDOC SlateDebugger.InvalidationRoot.Start - Starts the invalidation root widget debug tool. It shows when invalidation roots are using the slow or the fast path. SlateDebugger.InvalidationRoot.Stop - Stops the invalidation root widget debug tool. SlateDebugger.InvalidationRoot.Enable - Toggles (Start/Stop) the invalidation root widget debug tool to show when invalidation roots are using the slow or the fast path. SlateDebugger.InvalidationRoot.ToggleLegend - Toggles the display of the color legend. SlateDebugger.InvalidationRoot.ToggleWidgetNameList - Toggles the display of the name of the invalidation root. ``` -------------------------------- ### Slate Debugger: Invalidation Root Tracking (Invalidate) Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Tools for debugging widget invalidation roots, focusing on identifying invalidated widgets. Allows starting, stopping, and toggling display options, including legends, widget lists, and performance thresholds. ```APIDOC SlateDebugger.InvalidationRoot.Start - Starts the invalidation widget debug tool. It shows widgets that are invalidated. SlateDebugger.InvalidationRoot.Stop - Stops the invalidation widget debug tool. SlateDebugger.InvalidationRoot.Enabled - Toggles (Start/Stop) the invalidation widget debug tool to show widgets that are invalidated. SlateDebugger.InvalidationRoot.bShowLegend - Toggles the display of the color legend. SlateDebugger.InvalidationRoot.bShowWidgetList - Toggles the display of the names of the invalidation widgets. SlateDebugger.InvalidationRoot.bLogInvalidatedWidget - Toggles logging the invalidated widget to the console. SlateDebugger.InvalidationRoot.ThresholdPerformanceMS - For bUsePerformanceThreshold, specifies the threshold in milliseconds to reach before logging and/or displaying the invalidated widgets. SlateDebugger.InvalidationRoot.bUsePerformanceThreshold - Only displays the invalidated widgets and/or logs them if performance is worse than the specified threshold in milliseconds. SlateDebugger.InvalidationRoot.SetInvalidateRootReasonFilter - Enables/Disables specific invalidate root reason filters. - Filters: - None - ChildOrder - Root - ScreenPosition ``` -------------------------------- ### Getting Local Hit Location from World Location Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Calculates the 2D widget space location from a given world location. This involves transforming the world location into the component's local space and then mapping it to the 2D plane, accounting for draw size and pivot. ```C++ GetLocalHitLocation(); // Internal steps: // 1. Convert world location to relative space using InverseTransformPosition. // 2. Build 2D location: X-axis from negative relative Y, 2D Y-axis from negative relative Z. // 3. Offset 2D X by draw size X * Pivot X. // 4. Offset 2D Y by draw size Y * Pivot Y. // 5. Cache normalized location (2D location / draw size). // 6. Update 2D Y to account for parabola distortion using draw size Y * normalized Y. ``` -------------------------------- ### Slate Widget Event Declaration Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md Illustrates how to declare custom events for a Slate widget using the SLATE_EVENT macro. This macro allows widgets to expose delegates that can be bound to specific actions, such as hover events, enabling interactive behavior. The example shows declaring an FSimpleDelegate for an OnHovered event. ```C++ class SMyWidget : public SMyParentWidget { SLATE_DECLARE_WIDGET(SMyWidget, SMyParentWidget) public: SLATE_USER_ARGS( SMyWidget ) { // User arguments can be defined here if needed } /** Called when this widget is hovered. */ SLATE_EVENT( FSimpleDelegate, OnHovered) SLATE_END_ARGS() private: /** Called when this widget is hovered. */ FSimpleDelegate OnHovered; // FSimpleDelegate is within the engine BTW } ``` -------------------------------- ### Slate Widget Constructor Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Demonstrates the construction of a Slate widget, initializing member variables from input arguments. It highlights how to access properties using the underscore prefix. ```c++ void Construct( const FArguments& InArgs ) { // Order does not matter here but to get the property we need the underscore infront of the value we're getting. bCanBounce = InArgs._CanBounce; Style = InArgs._Style; AdditionalPadding = InArgs._AdditionalPadding; CustomizedScaling = InArgs._CustomizedScaling; } // Member variables: // float CustomizedScaling; // const FButtonStyle* Style; // TSlateAttribute AdditionalPadding; // TSlateAttribute bCanBounce; ``` -------------------------------- ### C++ File: SlateApplication.h Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Defines FSlateApplication, a core class for managing the Slate UI framework's application-level functionalities. It handles input, window management, and overall UI state. ```C++ SlateApplication.h ``` -------------------------------- ### Draw Widget to Texture with FWidgetRenderer (C++) Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Demonstrates how to render a `UUserWidget` to a `UTextureRenderTarget2D` using `FWidgetRenderer`. It covers initialization, drawing, and flushing rendering commands. This function handles creating the render target, setting its format, and using the widget renderer to draw the provided widget, ensuring proper rendering updates. ```C++ bool UExampleFunctionLibrary::DrawWidgetToTarget(UTextureRenderTarget2D*& DrawnWidgetRenderTarget, UUserWidget* WidgetToRender, const FVector2D DrawSize, const float DeltaTime) { // Reset the variable for Blueprint users to avoid reusing previous calls DrawnWidgetRenderTarget = nullptr; // Are we using a valid widget to grab from for the render target if(!IsValid(WidgetToRender)) { UE_LOG(LogExampleFunctionLibrary, Error, TEXT("UExampleFunctionLibrary::DrawWidgetToTarget: Inputted NULL WidgetToRender")); return false; } // Make sure we're using a valid draw size if(DrawSize.X <= 0 || DrawSize.Y <= 0) { UE_LOG(LogExampleFunctionLibrary, Error, TEXT("UExampleFunctionLibrary::DrawWidgetToTarget: Inputted INVALID DrawSize(%s)"), *DrawSize.ToString()); return false; } // Create the render target object using the user widget as the outer object(as a safety measure) DrawnWidgetRenderTarget = NewObject(WidgetToRender); // Setup the render target's size and formatting DrawnWidgetRenderTarget->InitCustomFormat(DrawSize.X, DrawSize.Y, FSlateApplication::Get().GetRenderer()->GetSlateRecommendedColorFormat(), true); // If we set this to false then it will not use linear gamma, but then we wouldn't get accurate coloring // This is the object that handles talking with the slate renderer to draw widgets as textures FWidgetRenderer* WidgetRenderer = new FWidgetRenderer(true, false); // FWidgetRenderer(bool bUseGammaCorrection = false, bool bInClearTarget = true) WidgetRenderer->DrawWidget(DrawnWidgetRenderTarget, WidgetToRender->TakeWidget(), DrawSize, DeltaTime, false); // THIS PARAMETER IS EXTREMELY IMPORTANT, this is for if you want to immediately update the render target. // bDeferRenderTargetUpdate: Whether or not the update is deferred until the end of the frame when it is potentially less expensive to update the render target. // Flush any queued rendering commands to immediately have the GPU draw the widget and get the texture information filled out FlushRenderingCommands(); // This is ANOTHER way of forcing the GPU to update the render target. // HINT HINT ^^^ // Deferred cleanup of the widget renderer to be deleted AFTER the render command queue has been flushed BeginCleanup(WidgetRenderer); return true; } ``` -------------------------------- ### Unreal Engine Input Flow Overview Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md An overview of the Unreal Engine's input processing pipeline, detailing the sequence of events from platform APIs to game code. It explains how input is routed through various engine systems like Slate Application, Input Processors, and UMG/Slate widgets. ```APIDOC Input Routing Stages: 1. Engine Heartbeat Tick (FEngineLoop): - Description: Notifies platform SDKs for Tick/Update each frame. 2. Platform APIs (GenericApplication, FGenericApplicationMessageHandler): - Description: SDKs for Windows/Mac/Xbox/Playstation etc., creating Slate application and sending input per frame. 3. Slate Application (FSlateApplication): - Description: Routes input between input processors, Slate UI, and the game engine. 4. Input Processors (IInputProcessor) - Optional: - Description: C++ objects that receive input before other operations, controlling consumption or routing. Can be dynamically added/removed. 5. Slate UI Elements (SWidget): - Description: UI elements on screen that receive and can use input. UMG Widgets (UWidget) are UObject wrappers for Slate Widgets. 6. Game Viewport Client (UGameViewportClient): - Description: Consumes input at a core level, routes it to the viewport widget, and then to the GameViewportClient for propagation to game code. 7. Player Controller (APlayerController): - Description: Receives input from the GameViewportClient, performs checks, and adds it to the input stack via ProcessPlayerInput. 8. Player Input (UPlayerInput): - Description: Object within PlayerController responsible for routing input to pawns and other objects on its input stack. 9. Input Component (UInputComponent): - Description: Component on actors that binds input events to delegate functions, receiving input via the engine's input stack. ``` -------------------------------- ### API: FSlateApplication Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md The main class for managing Slate application functionality. Provides access to the Slate rendering and input systems. ```APIDOC FSlateApplication: Documentation: https://docs.unrealengine.com/latest/INT/API/Runtime/Slate/Framework/Application/FSlateApplication/ ``` -------------------------------- ### Safe Zone Debugging Commands Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Commands for configuring and displaying safe zone overlays for UI development, ensuring content fits within defined display boundaries. ```APIDOC r.DebugSafeZone.TitleRatio [0.0-1.0] - Description: Sets the safe zone ratio returned by FDisplayMetrics::GetDisplayMetrics for platforms without a defined safe zone. Default is 1.0. - Parameters: - [0.0-1.0]: Float. The title safe zone ratio. ``` ```APIDOC r.DebugActionZone.ActionRatio [0.0-1.0] - Description: Sets the action zone ratio returned by FDisplayMetrics::GetDisplayMetrics for platforms without a defined safe zone. Default is 1.0. - Parameters: - [0.0-1.0]: Float. The action safe zone ratio. ``` ```APIDOC r.DebugSafeZone.Mode [integer between 0 and 2] - Description: Controls the display of the safe zone overlay. - Parameters: - [integer]: - 0: Do not display the safe zone overlay. - 1: Display the overlay for the title safe zone. - 2: Display the overlay for the action safe zone. ``` -------------------------------- ### API: UUserInterfaceSettings Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md Contains settings related to user interface rendering, including focus rules and other relevant data types. ```APIDOC UUserInterfaceSettings: Documentation: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UUserInterfaceSettings/ ``` -------------------------------- ### Rich Text Block Widget Painting Process Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/pages/text_widgets/rich_text_block.md Details the execution order and steps involved in the painting phase of the Rich Text Block Widget, focusing on how text layout and drawing are handled. ```APIDOC Rich Text Block :: OnPaint Execution Order: 1. Starts the draw phase by calculating the widget's geometry and screen position using the cached text layout. 2. Builds paint data by calling FSlateTextBlockLayout::OnPaint, which in turn calls FSlateTextLayout::OnPaint for actual drawing. 3. Recalculates the text layout, accounting for text wrapping based on the prepared paint data. 4. If the new layout size requires wrapping, invalidates the widget to update its geometry size in the hierarchy. ``` -------------------------------- ### API Doc: FSlateApplication Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md The central class for managing the Slate UI framework. It handles input events, window management, and the overall lifecycle of Slate applications. ```APIDOC FSlateApplication: [Documentation](https://docs.unrealengine.com/latest/INT/API/Runtime/Slate/Framework/Application/FSlateApplication/) ``` -------------------------------- ### API: UGameViewportClient Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md Represents the client viewport for the game, handling rendering and input for the game window. ```APIDOC UGameViewportClient: Documentation: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UGameViewportClient/ ``` -------------------------------- ### Unreal Engine Focusing System Components Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Explains the core elements of Unreal Engine's User Focus system for Slate/UMG, which manages which Slate Widget has focus for a given Slate User. ```APIDOC Unreal Engine Focusing System: - Concept: User Focus - only one Slate Widget can be focused at a time per Slate User. - Tracking: Managed by Slate Application using integer indices for Slate Users and focus paths. - Persistence: Focus persists between level/map travel; good practice to reset focus to the game viewport. - Key Elements: - Slate Application: - Handles tracking current widget focus and notifying of focus changes. - Signals the focusing system when an input is pressed. - HittestGrid: - Finds the next focusable widget using `FindNextFocusableWidget`. - Returns the found widget to the Slate Application. - SWidget: - Base functionality for all widgets, meant to be overridden. - `OnKeyDown`: Handles key press events when the widget has focus. - `OnNavigation`: Handles widget focus/loss of focus events. - Navigation Config: - Determines the navigation direction based on input. ``` -------------------------------- ### UMG User Widget Focus and Path Events Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Provides documentation for core User Widget events related to focus management and lifecycle within the Unreal Engine's UMG (Unreal Motion Graphics) framework. These events allow developers to hook into widget interactions like receiving or losing focus, and changes in the focus path. ```APIDOC UUserWidget Events: **On Focus Received** - Description: Occurs when focus is given to this User Widget exclusively. Requires returning an Event Reply struct (Handled or Unhandled). - Signature: virtual FReply UUserWidget::NativeOnFocusReceived( const FGeometry& InGeometry, const FFocusEvent& InFocusEvent ) - Parameters: - InGeometry: FGeometry - Geometry information about the widget. - InFocusEvent: FFocusEvent - Information about the focus event. - Returns: FReply - The reply from the widget, indicating if focus was handled. - Blueprint Usage: Override in the functions list, not the event graph, to return an Event Reply struct. **On Added to Focus Path** - Description: Occurs when this widget or a child widget within it is focused and added to the focus path, and was not previously part of it. - Signature: virtual void UUserWidget::NativeOnAddedToFocusPath(const FFocusEvent& InFocusEvent) - Parameters: - InFocusEvent: FFocusEvent - Information about the focus event. - Blueprint Usage: Call the BP version. **On Focus Lost** - Description: Occurs when this User Widget loses focus. - Signature: virtual void UUserWidget::NativeOnFocusLost( const FFocusEvent& InFocusEvent ) - Parameters: - InFocusEvent: FFocusEvent - Information about the focus event. - Blueprint Usage: Call the BP version. **On Removed from Focus Path** - Description: Similar to On Focus Lost, but occurs when this widget or a child widget is no longer part of the focus path. - Signature: virtual void UUserWidget::NativeOnRemovedFromFocusPath(const FFocusEvent& InFocusEvent) - Parameters: - InFocusEvent: FFocusEvent - Information about the focus event. - Blueprint Usage: Call the BP version. **Related Events**: OnAnimationFinished (mentioned in context but not detailed here). ``` -------------------------------- ### API: FNavigationConfig Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md Contains navigation-related types, including structures and enumerations, for managing user navigation within the engine. ```APIDOC FNavigationConfig: Documentation: https://docs.unrealengine.com/latest/INT/API/Runtime/Slate/Framework/Application/FNavigationConfig/ ``` -------------------------------- ### C++ Header: UnrealClient Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md Contains manager objects for viewport rendering and related functionalities. It also handles screenshot operations, with or without UI elements. ```C++ #include "UnrealClient.h" ``` -------------------------------- ### Unreal Engine Input Flow Components Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Lists the core components involved in Unreal Engine's input processing pipeline, from low-level platform interaction to game code integration. This outlines the sequence and responsibility of each stage. ```APIDOC UnrealEngineInputPipeline: Stages: 1. Engine Heartbeat Tick (FEngineLoop): - Description: Notifies platform SDKs to update every frame. - Responsibility: Core engine timing. 2. Platform API (GenericApplication & FGenericApplicationMessageHandler): - Description: SDKs for Windows, Mac, Xbox, etc., sending inputs to Slate Application. - Responsibility: Platform-specific input capture and forwarding. 3. Slate Application (FSlateApplication): - Description: Routes input between Input Processors, Slate UI, and game engine. - Responsibility: Central input routing hub. 4. Input Processors (IInputProcessor): - Description: Optional C++ objects that intercept input before other systems; can consume or pass input. - Recommendation: Create custom processors for full input control. - Example: AnalogCursor. - Responsibility: Pre-processing and filtering input. 5. Slate UI Elements (SWidget): - Description: Focused UI elements receiving input; UMG Widgets (UWidget) are wrappers for Slate Widgets. - Responsibility: UI-level input handling and consumption. 6. Game Viewport Client (UGameViewportClient): - Description: Receives unconsumed input from Slate elements and propagates it to the game engine. - Responsibility: Connecting Slate output to game engine logic. 7. Player Controller (APlayerController): - Description: Receives input via its Input Stack in `ProcessPlayerInput`. - Responsibility: Game-specific input processing and delegation. 8. Player Input (UPlayerInput): - Description: Object within Player Controller for routing input to pawns and other game objects. - Responsibility: Input routing within the game logic. 9. Input Component (UInputComponent): - Description: Commonly used object on Actors to receive input connected to the Player Controller's Input Stack. - Responsibility: Game code's primary interface for receiving input events. ``` -------------------------------- ### Slate Paint Debugger Commands Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Commands for debugging which widgets are painted each frame. This includes starting/stopping the tool, logging painted widgets, and configuring display options. ```APIDOC SlateDebugger.Paint.Start - Description: Starts the painted widget debug tool to show widgets painted this frame. SlateDebugger.Paint.Stop - Description: Stops the painted widget debug tool. SlateDebugger.Paint.Enable - Description: Toggles the painted widget debug tool (starts or stops it). SlateDebugger.Paint.LogOnce - Description: Logs the names of all widgets painted during the last update. SlateDebugger.Paint.MaxNumberOfWidgetDisplayedInList [MaxNumberOfWidgetsInList] - Description: Sets the maximum number of widgets displayed when the widget name list is active. - Parameters: - MaxNumberOfWidgetsInList: The maximum count of widgets to display. SlateDebugger.Paint.ToggleWidgetNameList - Description: Toggles the display of names for widgets that were painted. SlateDebugger.Paint.LogWarningIfWidgetIsPaintedMoreThanOnce - Description: Toggles logging a warning if a widget is painted multiple times in a single frame. SlateDebugger.Paint.OnlyGameWindow - Description: Toggles debugging to only include widgets within the game window. ``` -------------------------------- ### Slate Widget Arguments and Attributes Declaration Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md Demonstrates the use of Slate macros to declare widget arguments, default arguments, style arguments, and attributes. It shows how SLATE_BEGIN_ARGS and SLATE_END_ARGS frame the declarations, and how these are mapped to member variables in the Construct function. This pattern is crucial for creating customizable and reusable Slate widgets. ```C++ class SMyButtonWidget : public SMyParentWidget { SLATE_DECLARE_WIDGET(SMyButtonWidget, SMyParentWidget) public: /** Setup default values for these arguments, underscore is to avoid shadowing of member names */ SLATE_BEGIN_ARGS( SMyButtonWidget ) : _Style(&FCoreStyle::Get().GetWidgetStyle< FButtonStyle >( "Button" )) , _AdditionalPadding(FMargine(4.0f, 2.0f)) , _CanBounce(true) { } /** Scaling for after the button is customized */ SLATE_ARGUMENT_DEFAULT( float, CustomizedScaling ) = 1.0f; /** Visual style of the button */ SLATE_STYLE_ARGUMENT( FButtonStyle, Style ) /** Additional padding for what this button needs to display its visuals. */ SLATE_ATTRIBUTE( FMargin, AdditionalPadding ) /** For knowing if the button should be able to bounce when clicked. */ SLATE_ARGUMENT( bool, CanBounce ) SLATE_END_ARGS() /** * Construct this widget * * @param InArgs The declaration data for this widget */ void Construct( const FArguments& InArgs ) { // Order does not matter here but to get the property we need the underscore infront of the value we're getting. bCanBounce = InArgs._CanBounce; Style = InArgs._Style; AdditionalPadding = InArgs._AdditionalPadding; CustomizedScaling = InArgs._CustomizedScaling; } private: /** Scaling for after the button is customized */ float CustomizedScaling; /** Style resource for this custom button. */ const FButtonStyle* Style; /** Additional padding for what this button needs to display its visuals. */ TSlateAttribute AdditionalPadding; /** Flag to know if this button can be bounced when clicked. */ TSlateAttribute bCanBounce; } ``` -------------------------------- ### API: UWidgetBlueprintLibrary Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md A library of Blueprint-callable functions for interacting with UMG widgets, often referred to as 'WidgetLibrary'. ```APIDOC UWidgetBlueprintLibrary: Documentation: https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Blueprint/UWidgetBlueprintLibrary/ ``` -------------------------------- ### API: FEngineLoop Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md Represents the core of the entire Unreal Engine application. It is recommended to view this documentation for understanding but avoid direct modification. ```APIDOC FEngineLoop: Documentation: https://docs.unrealengine.com/latest/INT/API/Runtime/Launch/FEngineLoop/ ``` -------------------------------- ### C++ File: DeclarativeSyntaxSupport.h Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md This file is essential as it holds all the declarative syntax macros for Slate, such as SNew, SLATE_ARGUMENT, and others. Understanding these macros is key to using Slate's declarative UI definition. ```C++ DeclarativeSyntaxSupport.h ``` -------------------------------- ### C++ File: Widget.h Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Defines UWidget, the base class for Unreal Motion Graphics (UMG) UI components. UWidget bridges the gap between C++ and Blueprint for UI elements. ```C++ Widget.h ``` -------------------------------- ### UWidgetLayoutLibrary API Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Provides utility functions for managing widget layouts in Unreal Engine's UMG (Unreal Motion Graphics) system. This library aids in positioning, sizing, and arranging UI elements. ```APIDOC UWidgetLayoutLibrary: Purpose: Utility library for widget layout operations in UMG. Related Files: WidgetLayoutLibrary.h, WidgetLayoutLibrary.cpp Documentation Link: https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Blueprint/UWidgetLayoutLibrary/ ``` -------------------------------- ### UTextLayoutWidget Properties Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/pages/text_widgets/text_widget_overview.md Documentation for the properties of the UTextLayoutWidget, the base class for core text widgets in Unreal Engine. This includes detailed explanations of text shaping methods, flow directions, justification options, and wrapping policies. ```APIDOC UTextLayoutWidget: Base class for core text widgets. Properties: Shaped Text Options: Text Shaping Method: The method for how the text should be shaped. - Auto: Automatically picks the fastest possible shaping method (Kerning Only or Full Shaping) based on reading direction. LTR uses Kerning Only, RTL uses Full Shaping. - Kerning Only: Provides fake shaping using only kerning data. Faster but won't render RTL or bidirectional glyphs correctly. - Full Shaping: Provides full text shaping for accurate rendering of complex RTL or bidirectional glyphs, including ligature replacement. Text Flow Direction: The directions that text can flow within a paragraph. - Auto: Automatically detects the flow direction for each paragraph from its text. - Left to Right: Force text to be flowed left-to-right. - Right to Left: Force text to be flowed right-to-left. Justification: The orientation to align the text with the margin. - Left: Justify the text logically to the left. Aligns visually left for LTR, right for RTL. - Center: Justify the text logically to the center. Text flow direction does not affect this. - Right: Justify the text logically to the right. Aligns visually right for LTR, left for RTL. Wrapping Policy: The wrapping policy to use if a word is too long to be broken by the default line-break iterator. - Default Wrapping: No fallback, uses the default line-break iterator. - Allow Per Character Wrapping: Fallback to per-character wrapping if a word is too long. Auto Wrapping Text: Flag for if this text can automatically wrap based on the computed horizontal space. Wrapping Text At: Optional value for wrapping a new line when text exceeds a certain width. If less than or equal to zero, no wrapping occurs. Line Height Percentage: The amount of scaling to apply to each text line's height. Margin: The amount of blank space left around the edges of a text area (padding). ``` -------------------------------- ### API: IInputProcessor Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md The base interface class for input preprocessors. Custom input handling logic should inherit from this class. ```APIDOC IInputProcessor: Documentation: https://docs.unrealengine.com/latest/INT/API/Runtime/Slate/Framework/Application/IInputProcessor/ ``` -------------------------------- ### API: UWidgetLayoutLibrary Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md Provides Blueprint-callable functions for manipulating widget layouts and positions. ```APIDOC UWidgetLayoutLibrary: Documentation: https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Blueprint/UWidgetLayoutLibrary/ ``` -------------------------------- ### Slate Widget Key Elements Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Describes the fundamental components and functions that define a Slate Widget (SWidget), including layout calculation, rendering, and event handling. ```APIDOC Slate Widget (SWidget) Key Elements: Every Slate Widget is characterized by a set of core functions and values that govern its behavior and appearance. - **Compute Desired Size** (Function): - Purpose: Calculates the widget's preferred size during the first layout pass. - Details: This is a bottom-up calculation, ensuring children's desired sizes are computed first. - Related Value: **Slate Rect** (Value) - Defines the bounding box for desired size and layout, with origin at top-left, Y-axis downwards. - **Arrange Children** (Function): - Purpose: Arranges child widgets based on their desired sizes and the parent's allotted space during the second layout pass. - Details: This is a top-down process. - **On Paint** (Function): - Purpose: Responsible for generating the visual elements to be rendered by the system. - Details: Called every frame for visible widgets. - **Event Handlers** (Delegate values and/or Functions): - Purpose: Provides hooks for runtime UI changes based on events. - Details: Typically named in an "OnSomething" pattern (e.g., OnClicked). ``` -------------------------------- ### API: UWidget Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md The base class for UMG widgets, providing a Blueprint-accessible interface to Slate widgets. ```APIDOC UWidget: Documentation: https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Components/UWidget/ ``` -------------------------------- ### C++ File: LaunchEngineLoop.h Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Contains the definition for FEngineLoop, which is the central component managing the entire Unreal Engine application lifecycle. It's recommended for observation rather than direct modification. ```C++ LaunchEngineLoop.h ``` -------------------------------- ### API Doc: FEngineLoop Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Represents the core loop and management system of the Unreal Engine application. Provides access to engine initialization, tick, and shutdown processes. ```APIDOC FEngineLoop: [Documentation](https://docs.unrealengine.com/latest/INT/API/Runtime/Launch/FEngineLoop/) ``` -------------------------------- ### C++ File: SWidget.h Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md This file defines the base class SWidget for all Slate UI elements. It provides the fundamental structure and interface for creating interactive and visual components. ```C++ SWidget.h ``` -------------------------------- ### Bind to Slate Focus Changing Delegate Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md C++ code demonstrating how to bind a function to the `FSlateApplication::OnFocusChanging()` delegate within an Unreal Engine Player Controller. This allows listening for and reacting to focus changes across different users. ```C++ void AMyPlayerController::BeginPlay() { Super::BeginPlay(); // Valid check that slate application initialized if(FSlateApplication::IsInitialized()) { // Depending on your version of Unreal Engine, // you may need to just do "FSlateApplication::Get().FocusChangingDelegate" instead of using a function to get it // Bind for when focus changes, if you're having issues with this then I recommend learning about Unreal's delegate framework // or looking at the slate application's header and source file regarding the focus changing delegate FSlateApplication::Get().OnFocusChanging().AddUObject(this, &AMyPlayerController::FocusChanged); } } void AMyPlayerController::FocusChanged(const FFocusEvent& FocusEvent, const FWeakWidgetPath& OldFocusedWidgetPath, const TSharedPtr& OldFocusedWidget, const FWidgetPath& NewFocusedWidgetPath, const TSharedPtr& NewFocusedWidget) { // Check if this player controller has a valid local player object yet if(!IsValid(GetLocalPlayer())) { // If we don't have a valid local player object then don't continue because we're not done setting up the player controller return; } // Further logic to handle focus changes based on FocusEvent, Old/New widgets, and user index from FocusEvent } ``` -------------------------------- ### Slate Debugger Paint Commands Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/ru/README.md Controls for logging and displaying widget painting information. These settings help in understanding which widgets are being drawn and how often. ```APIDOC SlateDebugger.Paint.LogOnce - Description: Logs the names of all widgets that were rendered during the last update cycle in the tool. SlateDebugger.Paint.MaxNumberOfWidgetDisplayedInList [MaxNumberOfWidgetsInList] - Description: Sets the maximum number of widgets to display when the DisplayWidgetNameList is active in the tool. SlateDebugger.Paint.ToggleWidgetNameList - Description: Toggles the display of widget names that were rendered in the tool. SlateDebugger.Paint.LogWarningIfWidgetIsPaintedMoreThanOnce - Description: Enables logging a warning in the tool if a widget is painted more than once within a single frame. SlateDebugger.Paint.OnlyGameWindow - Description: Restricts the widget debugging information displayed in the tool to only those widgets belonging to the game window. ``` -------------------------------- ### UWidgetInteractionComponent Tick Process Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Details the step-by-step process the UWidgetInteractionComponent follows on each tick to determine widget interaction, including pointer movement, line tracing, and widget state updates. ```APIDOC UWidgetInteractionComponent::TickComponent - Simulates user inputs and pointer interactions with widget components. - Creates an FSlateUser to simulate input when activated. - Traces on tick to determine the widget under the pointer. Tick Frame Order: 1. UWidgetInteractionComponent::SimulatePointerMovement - Checks bEnableHitTesting. - Checks CanSendInput (Slate application initialized & virtual user setup). - Calls UWidgetInteractionComponent::DetermineWidgetUnderPointer. - Caches previously hovered widget component. - Calls UWidgetInteractionComponent::PerformTrace. - Line trace based on InteractionSource: - World: Multi-Line Trace by TraceChannel in forward direction, ignores owning actor components (except widget components). - Mouse: Multi-Line Trace by TraceChannel from deprojected mouse position. - Center Screen: Multi-Line Trace by TraceChannel from deprojected viewport center. - Custom: Uses CustomHitResult properties (set in BeginPlay for first tick). - Filters invisible widgets (unless Custom InteractionSource). - Gets hit widget component and returns 2D hit location in widget space. - Finds FWidgetPath from widget space hit location. - Returns trace result. - Tells newly hovered widget component to redraw. - Iterates through widgets from FWidgetPath to update flags: - bIsHoveredWidgetInteractable - bIsHoveredWidgetFocusable - bIsHoveredWidgetHitTestVisible - If hovered widget changed, tells previous component to redraw and broadcasts OnHoveredWidgetChanged. - Returns widget path from trace. - Notifies Slate application of input simulation or pointer movement off widget. ``` -------------------------------- ### API: UUserWidget Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/languages/zh/README.md The base class for UMG widgets created in Blueprints or C++. It allows for the creation and management of user interfaces. ```APIDOC UUserWidget: Documentation: https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Blueprint/UUserWidget/ ``` -------------------------------- ### C++ File: SUserWidget.h Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/README.md Contains the definition for SUserWidget, a Slate widget that can be created and managed by UUserWidget. It's a common base for custom UI widgets. ```C++ SUserWidget.h ``` -------------------------------- ### FLineModel Source: https://github.com/yawlighthouse/umg-slate-compendium/blob/main/pages/text_widgets/text_widget_overview.md Represents a single string with no manual breaks, intended as a line of text. It manages line-specific properties and operations efficiently, working in tandem with Text Layouts. ```APIDOC FLineModel: A container representing a single string with no manual breaks. Intended to be a representation of a line of text, its properties, line specific operations while staying efficient. Works in tandem with [Text Layouts]. ```