UIAnchor
Classes
- UIAnchor : Component
Note
UIFrame component is automatically added to the node if it is not already present
This component adjusts node’s position according to the parent UIFrame, using a specified anchor value
and top, right, bottom, and left insets.
Top-left corner of the screen corresponds to anchor = float2(0, 0), bottom-right is anchor = float2(1, 1).
Usage example:
var node = create_node()
add_component(node, new UIText(text:="Hello, world!"))
// text will be anchored to parent node with 10 pixels insets from all sides
add_component(node, new UIAnchor(
anchorMin = TOP_LEFT_ANCHOR, // equivalent to anchorMin = float2(0, 0)
anchorMax = BOTTOM_RIGHT_ANCHOR, // equivalent to anchorMax = float2(1, 1)
top = 10,
left = 10,
right = 10,
bottom = 10
))
- Fields:
anchorMin : float2 - Position anchor min value (top-left corner).
anchorMax : float2 - Position anchor max value (bottom-right corner).
left : float - Left inset in pixels.
top : float - Top inset in pixels.
right : float - Right inset in pixels.
bottom : float - Bottom inset in pixels.
- UIAnchor.apply_anchoring(frame: UIFrame?; parent: NodeId; parent_frame: UIFrame?)
Applies anchoring to the node using parent node. It is called automatically every frame.