UI Framework
Build user interfaces with frames, labels, and layout systems.
Related API Classes
UI Framework
StarForge's UI system is based on the UIBase class and uses UDim2 for flexible positioning that works across different screen sizes.
UDim2 Positioning
UDim2 combines scale (0-1) and offset (pixels) for each axis:
-- UDim2.new(xScale, xOffset, yScale, yOffset) -- Centered with 200x100 size local position = UDim2.new(0.5, -100, 0.5, -50) local size = UDim2.new(0, 200, 0, 100) -- Full width, 50px height at bottom local barPosition = UDim2.new(0, 0, 1, -50) local barSize = UDim2.new(1, 0, 0, 50) -- 50% width and height, centered local halfSize = UDim2.new(0.5, 0, 0.5, 0) local centered = UDim2.new(0.25, 0, 0.25, 0)
Creating UI Elements
-- Create a frame
local frame = new("UIFrame")
frame.Size = UDim2.new(0, 300, 0, 200)
frame.Position = UDim2.new(0.5, -150, 0.5, -100)
frame.BackgroundColor = Color.new(0.2, 0.2, 0.2, 0.9)
frame.Parent = uiLayer
-- Add a label
local label = new("UITextLabel")
label.Text = "Hello, World!"
label.Size = UDim2.new(1, -20, 0, 30)
label.Position = UDim2.new(0, 10, 0, 10)
label.TextColor = Color.White
label.Parent = frameUI Properties
Common UIBase properties:
Visible- Whether the element is renderedActive- Whether the element receives inputSelectable- Whether the element can be selectedFocusable- Whether the element can receive focus
Layout Modifiers
Modifiers like UICorner, UIStroke, and UIListLayout can be added as children to customize appearance and layout. See the API Reference for details.