DreamGUI
类参考

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

FunctionKindDescription
bool GetMousePositionOnPlatform(FVector2D& OutMousePosition)pureThe mouse in the PLATFORM's coordinates -- desktop pixels, across every monitor.
bool GetMousePositionOnViewport(UObject* WorldContextObject, FVector2D& OutMousePosition)pureThe mouse in viewport pixels, top-left zero.
bool GetMousePositionScaledByDPI(APlayerController* InPlayer, FVector2D& OutMousePosition)pureThe mouse in DPI-scaled viewport coordinates -- the space the UI is laid out in.
FDreamUIWidgetGeometry GetPlayerScreenWidgetGeometry(UObject* WorldContextObject, APlayerController* InPlayer)pureThe 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)pureThe 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)pureThe 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)pureWhere 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)pureThe same, and how far away it was. The distance is what a marker fades or sorts by.
void RemoveAllWidgets(UObject* WorldContextObject)callableTake every tracked page off the screen. UMG's RemoveAllWidgets.
UDreamPanelSlot* SlotAsPanelSlot(UDreamWidget* InWidget)pureA 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.

UMGMemberStatusHereNote
UWidgetLayoutLibraryProjectWorldLocationToWidgetPositionadoptProjectWorldLocationToWidgetPositionReturns bool and writes the position out, so a location behind the camera is reported rather than answered with a plausible number.
UWidgetLayoutLibraryProjectWorldLocationToWidgetPositionWithDistanceadoptProjectWorldLocationToWidgetPositionWithDistanceDistance 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.
UWidgetLayoutLibraryGetViewportScaleadoptGetViewportScaleReads the project's own UUserInterfaceSettings DPI curve, the same one UMG reads, so a project that tuned it once is obeyed by both.
UWidgetLayoutLibraryGetViewportSizeadoptGetViewportSize
UWidgetLayoutLibraryGetViewportWidgetGeometrymapGetPlayerScreenWidgetGeometryOne 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.
UWidgetLayoutLibraryGetPlayerScreenWidgetGeometryadoptGetPlayerScreenWidgetGeometryReads the screen root without creating one: asking about a geometry must not bring a screen into existence.
UWidgetLayoutLibraryGetMousePositionOnPlatformadoptGetMousePositionOnPlatformFalse when Slate is not running, so a headless caller can tell 'no cursor' from 'cursor at the origin'.
UWidgetLayoutLibraryGetMousePositionOnViewportadoptGetMousePositionOnViewport
UWidgetLayoutLibraryGetMousePositionScaledByDPIadoptGetMousePositionScaledByDPIReturns an FVector2D rather than UMG's two floats.
UWidgetLayoutLibrarySlotAsBorderSlotmapSlotAsPanelSlotOne UDreamPanelSlot class whatever the parent is, so the whole SlotAs* family collapses to one node and there is nothing to pick wrong.
UWidgetLayoutLibrarySlotAsCanvasSlotmapSlotAsPanelSlot
UWidgetLayoutLibrarySlotAsGridSlotmapSlotAsPanelSlot
UWidgetLayoutLibrarySlotAsHorizontalBoxSlotmapSlotAsPanelSlot
UWidgetLayoutLibrarySlotAsOverlaySlotmapSlotAsPanelSlot
UWidgetLayoutLibrarySlotAsUniformGridSlotmapSlotAsPanelSlot
UWidgetLayoutLibrarySlotAsVerticalBoxSlotmapSlotAsPanelSlot
UWidgetLayoutLibrarySlotAsScrollBoxSlotmapSlotAsPanelSlot
UWidgetLayoutLibrarySlotAsSafeBoxSlotmapSlotAsPanelSlot
UWidgetLayoutLibrarySlotAsScaleBoxSlotmapSlotAsPanelSlot
UWidgetLayoutLibrarySlotAsSizeBoxSlotmapSlotAsPanelSlot
UWidgetLayoutLibrarySlotAsStackBoxSlotmapSlotAsPanelSlot
UWidgetLayoutLibrarySlotAsWrapBoxSlotmapSlotAsPanelSlot
UWidgetLayoutLibrarySlotAsWidgetSwitcherSlotmapSlotAsPanelSlot
UWidgetLayoutLibraryRemoveAllWidgetsadoptRemoveAllWidgetsTakes every tracked page off the screen through UDreamScreenUISubsystem.
UWidgetLayoutLibraryGetDesignTimeInfomapUDreamUserWidget::IsDesignTimeUMG'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.

本页目录