UDreamUILayoutLibrary
The viewport, the mouse and the screen -- this framework's UWidgetLayoutLibrary.
本页由 DreamGUIReferenceDocs commandlet 从反射生成,正文是头文件注释的原文(英文),所以不翻译——这样它永远和代码一致。概念讲解见核心概念。
Inherits from UBlueprintFunctionLibrary.
Declared in Public/DreamUILayoutLibrary.h.
The viewport, the mouse and the screen -- this framework's UWidgetLayoutLibrary.
Everything here was reachable from C++ and from nowhere else: the viewport's size, its DPI scale, the mouse position in the coordinates the UI actually uses, and where a world location lands on screen. A Blueprint wanting to pin a marker to an enemy had to go through the UMG library, whose answers are in Slate's spaces and not this framework's, and hope the two agreed.
Functions
| Function | Kind | Description |
|---|---|---|
bool GetMousePositionOnPlatform(FVector2D& OutMousePosition) | pure | The mouse in the PLATFORM's coordinates -- desktop pixels, across every monitor. |
bool GetMousePositionOnViewport(UObject* WorldContextObject, FVector2D& OutMousePosition) | pure | The mouse in viewport pixels, top-left zero. |
bool GetMousePositionScaledByDPI(APlayerController* InPlayer, FVector2D& OutMousePosition) | pure | The mouse in DPI-scaled viewport coordinates -- the space the UI is laid out in. |
FDreamUIWidgetGeometry GetPlayerScreenWidgetGeometry(UObject* WorldContextObject, APlayerController* InPlayer) | pure | The geometry of the whole screen for a player -- UMG's GetViewportWidgetGeometry and GetPlayerScreenWidgetGeometry, which are one function here because there is one screen root per local player and no shared layer behind them. |
float GetViewportScale(UObject* WorldContextObject) | pure | The project's DPI scale for the current viewport size -- the number the whole UI is scaled by before it is shown. The same curve UMG reads, so a project that tuned it once is obeyed here. |
FVector2D GetViewportSize(UObject* WorldContextObject) | pure | The game viewport's size in pixels. Zero when there is no viewport, e.g. on a dedicated server. |
bool ProjectWorldLocationToWidgetPosition(APlayerController* InPlayer, FVector InWorldLocation, FVector2D& OutScreenPosition, bool bPlayerViewportRelative) | pure | Where a world location lands on screen, in viewport pixels -- what a health bar over an enemy needs. False when the location is behind the camera or there is no viewport. |
bool ProjectWorldLocationToWidgetPositionWithDistance(APlayerController* InPlayer, FVector InWorldLocation, FVector2D& OutScreenPosition, float& OutDistance, bool bPlayerViewportRelative) | pure | The same, and how far away it was. The distance is what a marker fades or sorts by. |
void RemoveAllWidgets(UObject* WorldContextObject) | callable | Take every tracked page off the screen. UMG's RemoveAllWidgets. |
UDreamPanelSlot* SlotAsPanelSlot(UDreamWidget* InWidget) | pure | A widget's panel slot -- UMG's whole SlotAs* family in one node. |
Compared with UMG
Every Blueprint-facing member of the UMG class, and where it went. adopt: same name, same meaning. map: here under another name or on another type. reject: deliberately absent, with the reason.
| UMG | Member | Status | Here | Note |
|---|---|---|---|---|
UWidgetLayoutLibrary | ProjectWorldLocationToWidgetPosition | adopt | ProjectWorldLocationToWidgetPosition | Returns bool and writes the position out, so a location behind the camera is reported rather than answered with a plausible number. |
UWidgetLayoutLibrary | ProjectWorldLocationToWidgetPositionWithDistance | adopt | ProjectWorldLocationToWidgetPositionWithDistance | Distance is a separate float rather than UMG's Z component of an FVector, and it is SIGNED along the view direction so a location behind the camera does not report the same depth as its mirror image in front. |
UWidgetLayoutLibrary | GetViewportScale | adopt | GetViewportScale | Reads the project's own UUserInterfaceSettings DPI curve, the same one UMG reads, so a project that tuned it once is obeyed by both. |
UWidgetLayoutLibrary | GetViewportSize | adopt | GetViewportSize | |
UWidgetLayoutLibrary | GetViewportWidgetGeometry | map | GetPlayerScreenWidgetGeometry | One function, because there is one screen root PER LOCAL PLAYER and no shared layer behind them -- the distinction UMG draws between AddToViewport and AddToPlayerScreen does not exist here. |
UWidgetLayoutLibrary | GetPlayerScreenWidgetGeometry | adopt | GetPlayerScreenWidgetGeometry | Reads the screen root without creating one: asking about a geometry must not bring a screen into existence. |
UWidgetLayoutLibrary | GetMousePositionOnPlatform | adopt | GetMousePositionOnPlatform | False when Slate is not running, so a headless caller can tell 'no cursor' from 'cursor at the origin'. |
UWidgetLayoutLibrary | GetMousePositionOnViewport | adopt | GetMousePositionOnViewport | |
UWidgetLayoutLibrary | GetMousePositionScaledByDPI | adopt | GetMousePositionScaledByDPI | Returns an FVector2D rather than UMG's two floats. |
UWidgetLayoutLibrary | SlotAsBorderSlot | map | SlotAsPanelSlot | One UDreamPanelSlot class whatever the parent is, so the whole SlotAs* family collapses to one node and there is nothing to pick wrong. |
UWidgetLayoutLibrary | SlotAsCanvasSlot | map | SlotAsPanelSlot | |
UWidgetLayoutLibrary | SlotAsGridSlot | map | SlotAsPanelSlot | |
UWidgetLayoutLibrary | SlotAsHorizontalBoxSlot | map | SlotAsPanelSlot | |
UWidgetLayoutLibrary | SlotAsOverlaySlot | map | SlotAsPanelSlot | |
UWidgetLayoutLibrary | SlotAsUniformGridSlot | map | SlotAsPanelSlot | |
UWidgetLayoutLibrary | SlotAsVerticalBoxSlot | map | SlotAsPanelSlot | |
UWidgetLayoutLibrary | SlotAsScrollBoxSlot | map | SlotAsPanelSlot | |
UWidgetLayoutLibrary | SlotAsSafeBoxSlot | map | SlotAsPanelSlot | |
UWidgetLayoutLibrary | SlotAsScaleBoxSlot | map | SlotAsPanelSlot | |
UWidgetLayoutLibrary | SlotAsSizeBoxSlot | map | SlotAsPanelSlot | |
UWidgetLayoutLibrary | SlotAsStackBoxSlot | map | SlotAsPanelSlot | |
UWidgetLayoutLibrary | SlotAsWrapBoxSlot | map | SlotAsPanelSlot | |
UWidgetLayoutLibrary | SlotAsWidgetSwitcherSlot | map | SlotAsPanelSlot | |
UWidgetLayoutLibrary | RemoveAllWidgets | adopt | RemoveAllWidgets | Takes every tracked page off the screen through UDreamScreenUISubsystem. |
UWidgetLayoutLibrary | GetDesignTimeInfo | map | UDreamUserWidget::IsDesignTime | UMG's struct carries the designer's preview size and flags. The only part of it that means anything at runtime here is 'am I in the designer', which is what a graph uses it for. |