UIScale
*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.
Một đối tượng UIScale chỉ chứa một số được sử dụng để nhân GuiBase2d.AbsoluteSize của phần UI cha. Số này được lưu trong UIScale.Scale .
Mẫu mã
This code sample creates some images of a lock and scales them using UIScale. It lays them out using a UIListLayout.
-- Lay out the images in a list
Instance.new("UIListLayout", script.Parent).SortOrder = Enum.SortOrder.LayoutOrder
-- Create some images of varying sizes using UIScale objects
for size = 0.2, 1.5, 0.2 do
local image = Instance.new("ImageLabel")
image.Image = "rbxassetid://284402752" -- an image of a Lock
image.Parent = script.Parent
image.Size = UDim2.new(0, 100, 0, 100)
-- Scale the image by adding a UIScale with the size
-- Note: this is a shorthand since we don't need a reference to the UIScale
Instance.new("UIScale", image).Scale = size
end
Tóm Tắt
Thuộc Tính
Xác định tỷ lệ để áp dụng cho kích thước của thành phần UI cha.
Thuộc Tính
Scale
Thuộc tính Scale xác định số nhân được sử dụng trên thành phần UI cha GuiBase2d.AbsoluteSize .Khi được đặt thành 0.5, một AbsoluteSize của 0, 200, 0, 50 trở thành 0, 100, 0, 25.Tương tự, khi đặt thành 2, một AbsoluteSize như vậy sẽ trở thành 0, 400, 0, 100.
Mẫu mã
This code sample creates some images of a lock and scales them using UIScale. It lays them out using a UIListLayout.
-- Lay out the images in a list
Instance.new("UIListLayout", script.Parent).SortOrder = Enum.SortOrder.LayoutOrder
-- Create some images of varying sizes using UIScale objects
for size = 0.2, 1.5, 0.2 do
local image = Instance.new("ImageLabel")
image.Image = "rbxassetid://284402752" -- an image of a Lock
image.Parent = script.Parent
image.Size = UDim2.new(0, 100, 0, 100)
-- Scale the image by adding a UIScale with the size
-- Note: this is a shorthand since we don't need a reference to the UIScale
Instance.new("UIScale", image).Scale = size
end