ImageButton

사용되지 않는 항목 표시

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

는 렌더링과 관련하여 추가 행동인 와 유사하게 동작합니다.

요약

속성

속성GuiButton에서 상속되었습니다속성GuiObject에서 상속되었습니다속성GuiBase2d에서 상속되었습니다

메서드

메서드GuiObject에서 상속되었습니다

이벤트

이벤트GuiButton에서 상속되었습니다이벤트GuiObject에서 상속되었습니다이벤트GuiBase2d에서 상속되었습니다

속성

HoverImage

ContentId
병렬 읽기

ImageButton가 호버될 때 사용될 텍스처 ID.

HoverImageContent

병렬 읽기

Image

ContentId
병렬 읽기

이 속성은 Roblox에 업로드된 데칼이나 이미지의 자산 ID를 보유해야 하는 콘텐츠 유형 속성입니다.Roblox에서 이미지를 로드하는 것과 관련하여 Decal.Texture와 동일하게 기능합니다.렌더링된 이미지는 ImageColor3를 사용하여 색상화됩니다.

이미지를 타일링, 크기를 조정하거나 9개로 슬라이스하여 렌더링하도록 설정하는 것이 가능한 점에 유의하십시오.Note that it is possible to make the image render as tiled, scaled to fit, or 9-sliced by adjusting the ScaleType property.

코드 샘플

This code sample causes an ImageLabel/ImageButton to display a red padlock. When the mouse is hovered, it changes to a green unlocked padlock.

Image Hover Lock

local imageLabel = script.Parent
-- The images in this example are 64x64
imageLabel.Size = UDim2.new(0, 64, 0, 64)
local function unlock()
imageLabel.Image = "rbxassetid://284402785" -- Unlocked padlock (64x64)
imageLabel.ImageColor3 = Color3.new(0, 0.5, 0) -- Dark green
end
local function lock()
imageLabel.Image = "rbxassetid://284402752" -- Locked padlock (64x64)
imageLabel.ImageColor3 = Color3.new(0.5, 0, 0) -- Dark red
end
-- Connect events; our default state is locked
imageLabel.MouseEnter:Connect(unlock)
imageLabel.MouseLeave:Connect(lock)
lock()

ImageColor3

병렬 읽기

이 속성은 이미지가 색상화되는 방법을 결정합니다.하얀색으로 설정하면 색상화가 발생하지 않습니다.이 속성은 이미지 자산을 재사용하는 데 매우 유용합니다: 원본 이미지가 투명도로 완전히 흰색이면 이 속성을 사용하여 이미지의 전체 색상을 한 번에 설정할 수 있습니다.

코드 샘플

This code sample causes an ImageLabel/ImageButton to display a red padlock. When the mouse is hovered, it changes to a green unlocked padlock.

Image Hover Lock

local imageLabel = script.Parent
-- The images in this example are 64x64
imageLabel.Size = UDim2.new(0, 64, 0, 64)
local function unlock()
imageLabel.Image = "rbxassetid://284402785" -- Unlocked padlock (64x64)
imageLabel.ImageColor3 = Color3.new(0, 0.5, 0) -- Dark green
end
local function lock()
imageLabel.Image = "rbxassetid://284402752" -- Locked padlock (64x64)
imageLabel.ImageColor3 = Color3.new(0.5, 0, 0) -- Dark red
end
-- Connect events; our default state is locked
imageLabel.MouseEnter:Connect(unlock)
imageLabel.MouseLeave:Connect(lock)
lock()

ImageContent

병렬 읽기

이 속성은 자산 URI 또는 EditableImage에 대한 참조를 보유해야 합니다.자산 URI는 Roblox에 업로드된 데칼이나 이미지를 참조할 수 있습니다.이미지 로드와 관련하여 동일하게 작동합니다 Decal.Texture .

렌더링된 이미지는 ImageColor3를 사용하여 색상화됩니다.이미지를 타일링, 크기를 조정하거나 9개로 슬라이스하여 렌더링할 수 있습니다.It is possible to make the image render as tiled, scaled to fit, or 9‑sliced by adjusting the ScaleType 속성.

ImageRectOffset

병렬 읽기

이 속성은 표시될 이미지 영역의 픽셀 오프셋(왼쪽 상단에서)을 결정하여 ImageRectSize와 함께 이미지의 부분 표시를 허용합니다.

코드 샘플

This code sample uses ImageRectOffset/ImageRectSize in order to play an animation of a man throwing a punch

Image Animation using Spritesheet

-- Place this in an ImageLabel/ImageButton with size 256x256
local imageLabel = script.Parent
-- The following image is 1024x1024 with 12 frames (256x256)
-- The frames play an animation of a man throwing a punch
imageLabel.Image = "rbxassetid://848623155"
imageLabel.ImageRectSize = Vector2.new(256, 256)
-- The order of the frames to be displayed (left-to-right, then top-to-bottom)
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),
}
-- Animate the frames one at a time in a loop
while true do
for _, frame in ipairs(frames) do
imageLabel.ImageRectOffset = frame * imageLabel.ImageRectSize
task.wait(0.1)
end
end

ImageRectSize

병렬 읽기

이 속성은 표시될 이미지 영역의 픽셀 크기를 결정하여 ImageRectOffset와 함께 이미지의 부분 표시를 허용합니다.두 차원 중 하나가 0로 설정되면 전체 이미지가 표시됩니다.

코드 샘플

This code sample uses ImageRectOffset/ImageRectSize in order to play an animation of a man throwing a punch

Image Animation using Spritesheet

-- Place this in an ImageLabel/ImageButton with size 256x256
local imageLabel = script.Parent
-- The following image is 1024x1024 with 12 frames (256x256)
-- The frames play an animation of a man throwing a punch
imageLabel.Image = "rbxassetid://848623155"
imageLabel.ImageRectSize = Vector2.new(256, 256)
-- The order of the frames to be displayed (left-to-right, then top-to-bottom)
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),
}
-- Animate the frames one at a time in a loop
while true do
for _, frame in ipairs(frames) do
imageLabel.ImageRectOffset = frame * imageLabel.ImageRectSize
task.wait(0.1)
end
end

ImageTransparency

병렬 읽기

이 속성은 요소의 렌더링된 이미지의 알파를 결정합니다.값 0 은 완전히 불투명하고 값 1 은 완전히 투명합니다(투명하지 않음).이 속성은 GuiObject.BackgroundTransparency 또는 BasePart.Transparency와 유사하게 동작합니다.

이미지 렌더링을 비활성화하여 ImageTransparency1 로 설정하면 버튼으로 사용할 수 있는 평범한 직사각형이 결과로 나타납니다.그러나 빈 TextButton 대신 사용하는 것이 더 좋을 수 있습니다.

IsLoaded

읽기 전용
복제되지 않음
병렬 읽기

이 속성은 Image 속성이 Roblox에서 로드를 완료했는지 여부를 나타냅니다. 조정으로 거부된 이미지는 결코 불러오다않습니다.

코드 샘플

This code sample measures how long an ImageLabel or ImageButton takes to load an image. If the image was already loaded, this will be 0.

Image Load Time

local imageLabel = script.Parent
local startTime = workspace.DistributedGameTime
-- Wait for the image to load
while not imageLabel.IsLoaded do
task.wait()
end
-- Measure and display how long it took to load
local deltaTime = workspace.DistributedGameTime - startTime
print(("Image loaded in %.3f seconds"):format(deltaTime))

PressedImage

ContentId
병렬 읽기

버튼이 누르면 이 이미지를 렌더링하는 ImageButton 속성으로 설정할 수 있는 텍스처 ID.

PressedImageContent

병렬 읽기

ResampleMode

병렬 읽기

크기가 조정될 때 이미지가 어떻게 보이는지 결정합니다.기본적으로 이미지는 텍스처 메모리에서 크기가 더 크거나 작을 때 텍스처의 질감을 부드럽게 처리합니다.반면에, Enum.ResamplerMode.Pixelated 이미지 픽셀의 날카로운 가장자리를 보존합니다.

병렬 읽기

이 속성은 UI 요소의 절대 크기가 원본 이미지의 크기와 다른 경우 Image 속성이 렌더링되는 방법을 결정합니다.

기본적으로 이 속성은 Enum.ScaleType.Stretch 로, 이미지 크기를 늘리거나 압축하여 UI 요소의 공간에 정확히 맞출 수 있습니다.투명한 픽셀은 Roblox에 업로드할 때 검은색으로 설정되므로 투명한 이미지는 확장된 이미지 주위에 검은색 테두리를 피하기 위해 알파 블렌딩을 적용해야 합니다.

For Enum.ScaleType.Slice , 크기를 늘릴 때 모서리는 원본 이미지 크기가 유지됩니다.이미지의 가장자리가 이미지의 너비/높이로 확장됩니다.마지막으로, 이미지의 중앙이 확장되어 이미지의 중앙 영역을 채울 것입니다.9슬라이스 이미지에 대해 자세히 알아보려면 UI 9슬라이스 디자인을 참조하십시오.

For Enum.ScaleType.Tile , 각 이미지 타일의 크기는 TileSize 속성에 의해 결정됩니다.

SliceCenter

병렬 읽기

이 속성은 ScaleTypeEnum.ScaleType.Slice 로 설정되었을 때 9개의 이미지 조각의 경계를 설정합니다.

9개의 슬라이스된 이미지에 대해 자세히 알아보려면 UI 9개의 슬라이스 디자인을 참조하십시오.

SliceScale

병렬 읽기

지정된 비율로 9개의 가장자리를 확장합니다.즉, 9개의 조각 주변의 가장자리가 업스케일된 새 버전의 텍스처를 업로드한 것처럼 성장할 것입니다.기본값은 1.0 입니다.

9-슬라이스의 경계에 대한 배수로, 여러 반지름에 대해 한 개의 둥근 모서리 이미지를 재사용하는 데 유용합니다.

또한 소스 이미지와 크기가 다른 UI 요소에 표시되는 경우 이미지가 어떻게 크기를 조정할지 결정하는 ScaleType도 참조하십시오.

TileSize

병렬 읽기

이미지의 왼쪽 상단 모서리에서 시작하여 타일링 크기를 설정합니다 ImageButton .기본값 은 ; 스케일 구성 요소의 는 크기에 따라 타일을 확장하고 오프셋 구성 요소는 원시 픽셀에 있습니다.예를 들어, 0.5의 비율은 타일이 해당 축에서 ImageButton의 크기의 절반이 될 것임을 의미합니다.

이 속성은 ScaleType 속성이 Enum.ScaleType.Tile로 설정된 경우에만 활성입니다.

메서드

이벤트