中EN

Lyra Cross-platform UI Development (Nick Darnell, Epic Games) — Tech Talk, State of Unreal 2022

  • Input routing: CommonUIActionRouterBase is a local player subsystem; action bindings registered with it decide whether an action fires. Slate input travels up widget hierarchy to the Viewport → ViewportClient → player input. Project replaces viewport client with a CommonGameViewportClient subclass (LyraGameViewportClient) so input is funneled to the action router first; if not handled, passes to player controller.
  • Actions defined in data tables (Universal Actions: Back = Face Button Right; Apply/Cancel), with display name and keyboard/gamepad keys.
  • CommonActivatableWidget: Activated/Deactivated differ from Construct/Destruct — "you can be deactivated and still constructed". "What's most important is that you are the root-most activated widget. That determines whether or not you and all of your activated children widgets get input routed to you." Root determined by which activatable widget is painted highest. Debug: CommonUI.DumpActivatableTree.
  • Add To Viewport doesn't maintain hierarchy (modals on top of HUD). Lyra: GameUIManagerSubsystem (CommonGame plugin, part of Lyra, not engine) monitors players and tells UI Policy (LyraUIPolicy) to add PrimaryGameLayout per player (OverallUILayout).
  • Layout sets up stacks: GameLayer Stack (HUD), GameMenu Stack (inventory), Menu Stack (settings/frame), Modal Stack (exit-game questions). These are CommonActivatableWidgetStacks; Common UI ships a stack and a queue; pushing supplants current widget in that layer, deactivating returns to previous. Layers registered with Primary Game Layout using gameplay tags (Game, Game Menu, Menu, Modal). Controller-disconnected UI should be a hidden widget in the overall layout, not a stack.
  • Push Content To Layer For Player (Lyra-only) takes soft class reference — "if you use a hard reference to your UI classes... your screens, they'll quickly load all other screens". Suspends input until async loaded and activated to avoid button-mash bugs. Native: PushWidgetToLayerStackAsync with suspend input.
  • CommonHardwareVisibilityBorder filters widgets by platform trait / input type gameplay tags (e.g. CanExitApplication).

引用这一章的笔记

输入关键词开始搜索

滚轮或双指缩放 · 拖动平移 · 双击放大 / 还原