Engine Class
ImageLabel
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
คุณสมบัติ
Image:ContentId |
เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
Image
ImageLabel.Image:ContentId
ImageTransparency
ตัวอย่างโค้ด
การเปลี่ยนแปลง ImageTransparency
local RunService = game:GetService("RunService")
local imageLabel = script.Parent
local function onRenderStep()
-- เปลี่ยนแปลง ImageTransparency จาก 0 เป็น 1 โดยใช้คลื่นไซน์
imageLabel.ImageTransparency = math.sin(workspace.DistributedGameTime * math.pi) * 0.5 + 0.5
end
RunService.RenderStepped:Connect(onRenderStep)IsLoaded
ตัวอย่างโค้ด
เวลาโหลดภาพ
local imageLabel = script.Parent
local startTime = workspace.DistributedGameTime
-- รอให้ภาพโหลด
while not imageLabel.IsLoaded do
task.wait()
end
-- วัดและแสดงว่าใช้เวลาในการโหลดนานเท่าไหร่
local deltaTime = workspace.DistributedGameTime - startTime
print(("โหลดภาพเสร็จใน %.3f วินาที"):format(deltaTime))TileSize
ตัวอย่างโค้ด
สาธิตประเภทขนาดภาพ
local imageLabel = script.Parent
-- ตั้งค่าภาพต้นทางให้เป็นกลอนขนาด 64x64
imageLabel.Image = "rbxassetid://284402752"
imageLabel.BackgroundTransparency = 0
imageLabel.BackgroundColor3 = Color3.new(1, 1, 1) -- ขาว
imageLabel.ImageColor3 = Color3.new(0, 0, 0) -- ดำ
local function resizeInACircle()
for theta = 0, 2, 0.02 do
imageLabel.Size =
UDim2.new(0, 100 + math.cos(theta * 2 * math.pi) * 50, 0, 100 + math.sin(theta * 2 * math.pi) * 50)
task.wait()
end
end
while true do
-- ยืดจะทำการยืดภาพต้นทางให้พอดีกับ
-- พื้นที่ของ UI element
imageLabel.ScaleType = Enum.ScaleType.Stretch
resizeInACircle()
-- ปูจะเรนเดอร์ภาพต้นทางหลายครั้ง
-- เพียงพอที่จะเติมพื้นที่ของ UI element
imageLabel.ScaleType = Enum.ScaleType.Tile
imageLabel.TileSize = UDim2.new(0, 64, 0, 64)
resizeInACircle()
-- ตัดจะทำให้ภาพกลายเป็น UI แบบเก้าเบี้ย
imageLabel.ScaleType = Enum.ScaleType.Slice
imageLabel.SliceCenter = Rect.new(30, 30, 34, 34)
resizeInACircle()
end