Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UI = {}
- -- 常量
- local FONT = Enum.Font.SourceSans
- local FONT_SIZE = Enum.FontSize.Size18
- local TEXT_COLOR = Color3.fromRGB(255, 255, 255)
- local BUTTON_COLOR = Color3.fromRGB(43, 143, 255)
- local BUTTON_HOVER_COLOR = Color3.fromRGB(53, 153, 255)
- -- 创建UI元素
- function UI.CreateTextLabel(parent, text, position, size)
- local label = Instance.new("TextLabel")
- label.Size = size or UDim2.new(0, 200, 0, 50)
- label.Position = position or UDim2.new(0, 0, 0, 0)
- label.BackgroundTransparency = 1
- label.Text = text or ""
- label.Font = FONT
- label.TextSize = FONT_SIZE
- label.TextColor3 = TEXT_COLOR
- label.TextWrapped = true
- label.Parent = parent
- return label
- end
- function UI.CreateTextButton(parent, text, position, size, callback)
- local button = Instance.new("TextButton")
- button.Size = size or UDim2.new(0, 200, 0, 50)
- button.Position = position or UDim2.new(0, 0, 0, 0)
- button.Text = text or ""
- button.Font = FONT
- button.TextSize = FONT_SIZE
- button.TextColor3 = TEXT_COLOR
- button.BackgroundColor3 = BUTTON_COLOR
- button.AutoButtonColor = false
- button.BorderSizePixel = 0
- button.MouseEnter:Connect(function()
- button.BackgroundColor3 = BUTTON_HOVER_COLOR
- end)
- button.MouseLeave:Connect(function()
- button.BackgroundColor3 = BUTTON_COLOR
- end)
- button.Parent = parent
- if callback then
- button.MouseButton1Click:Connect(callback)
- end
- return button
- end
- function UI.CreateTextBox(parent, text, position, size)
- local textbox = Instance.new("TextBox")
- textbox.Size = size or UDim2.new(0, 200, 0, 50)
- textbox.Position = position or UDim2.new(0, 0, 0, 0)
- textbox.BackgroundTransparency = 0.5
- textbox.BackgroundColor3 = Color3.new(1, 1, 1)
- textbox.Text = text or ""
- textbox.Font = FONT
- textbox.TextSize = FONT_SIZE
- textbox.TextColor3 = TEXT_COLOR
- textbox.ClearTextOnFocus = false
- textbox.Parent = parent
- return textbox
- end
- return UI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement