Advertisement
NightGolden

1111

Mar 11th, 2023 (edited)
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. local UI = {}
  2.  
  3. -- 常量
  4. local FONT = Enum.Font.SourceSans
  5. local FONT_SIZE = Enum.FontSize.Size18
  6. local TEXT_COLOR = Color3.fromRGB(255, 255, 255)
  7. local BUTTON_COLOR = Color3.fromRGB(43, 143, 255)
  8. local BUTTON_HOVER_COLOR = Color3.fromRGB(53, 153, 255)
  9.  
  10. -- 创建UI元素
  11. function UI.CreateTextLabel(parent, text, position, size)
  12. local label = Instance.new("TextLabel")
  13. label.Size = size or UDim2.new(0, 200, 0, 50)
  14. label.Position = position or UDim2.new(0, 0, 0, 0)
  15. label.BackgroundTransparency = 1
  16. label.Text = text or ""
  17. label.Font = FONT
  18. label.TextSize = FONT_SIZE
  19. label.TextColor3 = TEXT_COLOR
  20. label.TextWrapped = true
  21. label.Parent = parent
  22. return label
  23. end
  24.  
  25. function UI.CreateTextButton(parent, text, position, size, callback)
  26. local button = Instance.new("TextButton")
  27. button.Size = size or UDim2.new(0, 200, 0, 50)
  28. button.Position = position or UDim2.new(0, 0, 0, 0)
  29. button.Text = text or ""
  30. button.Font = FONT
  31. button.TextSize = FONT_SIZE
  32. button.TextColor3 = TEXT_COLOR
  33. button.BackgroundColor3 = BUTTON_COLOR
  34. button.AutoButtonColor = false
  35. button.BorderSizePixel = 0
  36. button.MouseEnter:Connect(function()
  37. button.BackgroundColor3 = BUTTON_HOVER_COLOR
  38. end)
  39. button.MouseLeave:Connect(function()
  40. button.BackgroundColor3 = BUTTON_COLOR
  41. end)
  42. button.Parent = parent
  43. if callback then
  44. button.MouseButton1Click:Connect(callback)
  45. end
  46. return button
  47. end
  48.  
  49. function UI.CreateTextBox(parent, text, position, size)
  50. local textbox = Instance.new("TextBox")
  51. textbox.Size = size or UDim2.new(0, 200, 0, 50)
  52. textbox.Position = position or UDim2.new(0, 0, 0, 0)
  53. textbox.BackgroundTransparency = 0.5
  54. textbox.BackgroundColor3 = Color3.new(1, 1, 1)
  55. textbox.Text = text or ""
  56. textbox.Font = FONT
  57. textbox.TextSize = FONT_SIZE
  58. textbox.TextColor3 = TEXT_COLOR
  59. textbox.ClearTextOnFocus = false
  60. textbox.Parent = parent
  61. return textbox
  62. end
  63.  
  64. return UI
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement