API 참조
메서드
GetGuiObjectsAtPosition
반환
Instances
코드 샘플
위치에서 GUI 선택하기
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
-- 하이라이트 프레임을 포함할 폴더와 ScreenGui 생성
local highlights = Instance.new("Folder")
highlights.Name = "Highlights"
highlights.Parent = playerGui
local highlightsContainer = Instance.new("ScreenGui")
highlightsContainer.Name = "Container"
highlightsContainer.Parent = highlights
highlightsContainer.DisplayOrder = 99999
-- GUI 위에 동일한 AbsoluteSize 및 AbsolutePosition을 가진 반투명 노란색 프레임 생성
local function highlightAsFrame(gui)
local highlight = Instance.new("Frame")
highlight.Name = "Highlight"
highlight.Parent = highlightsContainer
highlight.Size = UDim2.new(0, gui.AbsoluteSize.X, 0, gui.AbsoluteSize.Y)
highlight.Position = UDim2.new(0, gui.AbsolutePosition.X, 0, gui.AbsolutePosition.Y)
highlight.BackgroundColor3 = Color3.fromRGB(255, 255, 10) -- 노란색
highlight.BackgroundTransparency = 0.75
highlight.BorderSizePixel = 0
highlight.LayoutOrder = gui.LayoutOrder - 1
end
-- GetGuiObjectsAtPosition을 사용하여 입력 위치에 있는 모든 GuiObjects를 가져와 하이라이트
local function highlightGui(input, _gameProcessed)
local pos = input.Position
local guisAtPosition = playerGui:GetGuiObjectsAtPosition(pos.X, pos.Y)
highlightsContainer:ClearAllChildren()
for _, gui in ipairs(guisAtPosition) do
if gui:IsA("GuiObject") then
highlightAsFrame(gui)
end
end
end
-- 입력이 MouseButton1 또는 Touch 타입인 경우 InputBegan에서 highlightGui 실행
local function InputBegan(input, gameProcessed)
local inputType = input.UserInputType
local touch = Enum.UserInputType.Touch
local mouse1 = Enum.UserInputType.MouseButton1
if inputType == touch or inputType == mouse1 then
highlightGui(input, gameProcessed)
end
end
UserInputService.InputBegan:Connect(InputBegan)