เรียนรู้
Engine Class
ImageButton

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
สมาชิกที่ได้รับทอด

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
HoverImage
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.HoverImage:ContentId

HoverImageContent
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.HoverImageContent:Content

Image
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.Image:ContentId
ตัวอย่างโค้ด
ล็อคภาพเมื่อชี้เมาส์
local imageLabel = script.Parent
-- รูปภาพในตัวอย่างนี้มีขนาด 64x64
imageLabel.Size = UDim2.new(0, 64, 0, 64)
local function unlock()
imageLabel.Image = "rbxassetid://284402785" -- Padlock ที่ปลดล็อคแล้ว (64x64)
imageLabel.ImageColor3 = Color3.new(0, 0.5, 0) -- สีเขียวเข้ม
end
local function lock()
imageLabel.Image = "rbxassetid://284402752" -- Padlock ที่ล็อคแล้ว (64x64)
imageLabel.ImageColor3 = Color3.new(0.5, 0, 0) -- สีแดงเข้ม
end
-- เชื่อมต่อเหตุการณ์; สถานะเริ่มต้นของเราคือถูกล็อค
imageLabel.MouseEnter:Connect(unlock)
imageLabel.MouseLeave:Connect(lock)
lock()

ImageColor3
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.ImageColor3:Color3
ตัวอย่างโค้ด
ล็อคภาพเมื่อชี้เมาส์
local imageLabel = script.Parent
-- รูปภาพในตัวอย่างนี้มีขนาด 64x64
imageLabel.Size = UDim2.new(0, 64, 0, 64)
local function unlock()
imageLabel.Image = "rbxassetid://284402785" -- Padlock ที่ปลดล็อคแล้ว (64x64)
imageLabel.ImageColor3 = Color3.new(0, 0.5, 0) -- สีเขียวเข้ม
end
local function lock()
imageLabel.Image = "rbxassetid://284402752" -- Padlock ที่ล็อคแล้ว (64x64)
imageLabel.ImageColor3 = Color3.new(0.5, 0, 0) -- สีแดงเข้ม
end
-- เชื่อมต่อเหตุการณ์; สถานะเริ่มต้นของเราคือถูกล็อค
imageLabel.MouseEnter:Connect(unlock)
imageLabel.MouseLeave:Connect(lock)
lock()

ImageContent
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.ImageContent:Content

ImageRectOffset
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.ImageRectOffset:Vector2
ตัวอย่างโค้ด
การแอนิเมชันภาพโดยใช้ Spritesheet
-- วางสิ่งนี้ใน ImageLabel/ImageButton ขนาด 256x256
local imageLabel = script.Parent
-- ภาพต่อไปนี้มีขนาด 1024x1024 มี 12 เฟรม (256x256)
-- เฟรมต่างๆ จะแสดงการแอนิเมชันของผู้ชายที่กำลังโยนหมัด
imageLabel.Image = "rbxassetid://848623155"
imageLabel.ImageRectSize = Vector2.new(256, 256)
-- ลำดับของเฟรมที่จะแสดง (จากซ้ายไปขวา จากบนลงล่าง)
local frames = {
Vector2.new(0, 0),
Vector2.new(1, 0),
Vector2.new(2, 0),
Vector2.new(3, 0),
Vector2.new(0, 1),
Vector2.new(1, 1),
Vector2.new(2, 1),
Vector2.new(3, 1),
Vector2.new(0, 2),
Vector2.new(1, 2),
Vector2.new(2, 2),
Vector2.new(3, 2),
}
-- แอนิเมตเฟรมทีละเฟรมในลูป
while true do
for _, frame in ipairs(frames) do
imageLabel.ImageRectOffset = frame * imageLabel.ImageRectSize
task.wait(0.1)
end
end

ImageRectSize
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.ImageRectSize:Vector2
ตัวอย่างโค้ด
การแอนิเมชันภาพโดยใช้ Spritesheet
-- วางสิ่งนี้ใน ImageLabel/ImageButton ขนาด 256x256
local imageLabel = script.Parent
-- ภาพต่อไปนี้มีขนาด 1024x1024 มี 12 เฟรม (256x256)
-- เฟรมต่างๆ จะแสดงการแอนิเมชันของผู้ชายที่กำลังโยนหมัด
imageLabel.Image = "rbxassetid://848623155"
imageLabel.ImageRectSize = Vector2.new(256, 256)
-- ลำดับของเฟรมที่จะแสดง (จากซ้ายไปขวา จากบนลงล่าง)
local frames = {
Vector2.new(0, 0),
Vector2.new(1, 0),
Vector2.new(2, 0),
Vector2.new(3, 0),
Vector2.new(0, 1),
Vector2.new(1, 1),
Vector2.new(2, 1),
Vector2.new(3, 1),
Vector2.new(0, 2),
Vector2.new(1, 2),
Vector2.new(2, 2),
Vector2.new(3, 2),
}
-- แอนิเมตเฟรมทีละเฟรมในลูป
while true do
for _, frame in ipairs(frames) do
imageLabel.ImageRectOffset = frame * imageLabel.ImageRectSize
task.wait(0.1)
end
end

ImageTransparency
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.ImageTransparency:number

IsLoaded
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.IsLoaded:boolean
ตัวอย่างโค้ด
เวลาโหลดภาพ
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))

PressedImage
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.PressedImage:ContentId

PressedImageContent
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.PressedImageContent:Content

ResampleMode
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.ResampleMode:Enum.ResamplerMode

ScaleType
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.ScaleType:Enum.ScaleType

SliceCenter
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.SliceCenter:Rect

SliceScale
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.SliceScale:number

TileSize
อ่านพร้อมๆ กัน
ความสามารถ: UI
ImageButton.TileSize:UDim2

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ