UIScale

顯示已棄用項目

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

UIScale 對象只包含用於乘以父 UI 元素 GuiBase2d.AbsoluteSize 的數字。這個數字被儲存在 UIScale.Scale 中。

範例程式碼

This code sample creates some images of a lock and scales them using UIScale. It lays them out using a UIListLayout.

UI Scale Demo

-- 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

屬性

Scale

平行讀取

縮放屬性決定在父 UI 元素的 GuiBase2d.AbsoluteSize 上使用的乘數。當設為 0.5 時,0、200、0、50 的絕對尺寸變為 0、100、0、25。相同地,當設為 2 時,這種絕對尺寸將變為 0、400、0、100。

範例程式碼

This code sample creates some images of a lock and scales them using UIScale. It lays them out using a UIListLayout.

UI Scale Demo

-- 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

方法

活動