Lớp công cụ
GuiService
*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.
Tóm Tắt
Thuộc Tính
Phương Pháp
AddSelectionParent(selectionName: string,selectionParent: Instance):() |
AddSelectionTuple(selectionName: string,selections: Tuple):() |
CloseInspectMenu():() |
DismissNotification(notificationId: string):boolean |
GetInsetArea(screenInsets: Enum.ScreenInsets):Rect |
InspectPlayerFromHumanoidDescription(humanoidDescription: Instance,name: string):() |
InspectPlayerFromUserId(userId: User):() |
RemoveSelectionGroup(selectionName: string):() |
SendNotification(notificationInfo: Dictionary):string |
SetEmotesMenuOpen(isOpen: boolean):() |
SetGameplayPausedNotificationEnabled(enabled: boolean):() |
SetInspectMenuEnabled(enabled: boolean):() |
Sự Kiện
Tài Liệu Tham Khảo API
Thuộc Tính
IsModalDialog
IsWindows
PreferredTextSize
Mẫu mã
Phát hiện/Áp dụng thay đổi kích thước văn bản ưa thích
local GuiService = game:GetService("GuiService")
local TextService = game:GetService("TextService")
local FONT_SIZE = 25
local PADDING = 8
local textLabel = Instance.new("TextLabel")
textLabel.Position = UDim2.new(0.5, 0, 0.5, 0)
textLabel.AnchorPoint = Vector2.new(0.5, 0.5)
textLabel.AutomaticSize = Enum.AutomaticSize.X
textLabel.TextSize = FONT_SIZE + PADDING
textLabel.Text = "Kiểm tra nhãn văn bản"
textLabel.Parent = script.Parent
local function applyAddedTextHeight()
local finalTextHeight = TextService:GetTextSize("", FONT_SIZE, Enum.Font.BuilderSans, Vector2.new(math.huge, math.huge)).Y
local addedTextHeight = finalTextHeight - FONT_SIZE
print("PreferredTextSize thêm", addedTextHeight, " vào kích thước văn bản mặc định")
textLabel.Size = UDim2.new(0, 0, 0, FONT_SIZE + addedTextHeight + PADDING)
end
applyAddedTextHeight()
GuiService:GetPropertyChangedSignal("PreferredTextSize"):Connect(applyAddedTextHeight)PreferredTransparency
Mẫu mã
Phát hiện/Áp dụng thay đổi độ trong suốt ưu tiên
local GuiService = game:GetService("GuiService")
local CollectionService = game:GetService("CollectionService")
local TAG = "TransparentBack"
local transparentBackObjects = {}
local function onInstanceAdded(object)
if object.BackgroundTransparency then
local defaultTransparency = object.BackgroundTransparency
transparentBackObjects[object] = defaultTransparency
object.BackgroundTransparency = defaultTransparency * GuiService.PreferredTransparency
end
end
local function onInstanceRemoved(object)
transparentBackObjects[object] = nil
end
-- Lưu trữ các thể hiện gán thẻ ban đầu
for _, object in CollectionService:GetTagged(TAG) do
onInstanceAdded(object)
end
-- Phát hiện khi một thể hiện gán thẻ được thêm hoặc xóa
CollectionService:GetInstanceAddedSignal(TAG):Connect(onInstanceAdded)
CollectionService:GetInstanceRemovedSignal(TAG):Connect(onInstanceRemoved)
-- Khi cài đặt trong trò chơi được thay đổi, điều chỉnh các thể hiện gán thẻ
GuiService:GetPropertyChangedSignal("PreferredTransparency"):Connect(function()
for object, defaultTransparency in transparentBackObjects do
object.BackgroundTransparency = defaultTransparency * GuiService.PreferredTransparency
end
end)SelectedObject
Mẫu mã
In thông báo khi thay đổi lựa chọn Gamepad
local GuiService = game:GetService("GuiService")
local function printChanged(value)
if value == "SelectedObject" then
print("SelectedObject đã thay đổi!")
end
end
GuiService.Changed:Connect(printChanged)TopbarInset
Mẫu mã
Khung phản hồi trong không gian thanh trên có sẵn
local GuiService = game:GetService("GuiService")
local Players = game:GetService("Players")
local screenGui = Instance.new("ScreenGui")
screenGui.IgnoreGuiInset = true
screenGui.Parent = Players.LocalPlayer.PlayerGui
local frame = Instance.new("Frame")
frame.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
frame.Parent = screenGui
GuiService:GetPropertyChangedSignal("TopbarInset"):Connect(function()
local inset = GuiService.TopbarInset
frame.Size = UDim2.new(0, inset.Width, 0, inset.Height)
frame.Position = UDim2.new(0, inset.Min.X, 0, inset.Min.Y)
end)ViewportDisplaySize
Mẫu mã
Thay đổi Kích thước Hiển thị Khung nhìn
local GuiService = game:GetService("GuiService")
local function updateUI()
if (GuiService.ViewportDisplaySize == Enum.DisplaySize.Small) then
-- Cập nhật UI cho màn hình nhỏ
elseif (GuiService.ViewportDisplaySize == Enum.DisplaySize.Large) then
-- Cập nhật UI cho màn hình lớn
else
-- Cập nhật UI cho màn hình trung bình/mặc định
end
end
GuiService:GetPropertyChangedSignal("ViewportDisplaySize"):Connect(updateUI)
updateUI()Phương Pháp
AddSelectionParent
AddSelectionTuple
CloseInspectMenu
GuiService:CloseInspectMenu():()
Lợi Nhuận
()
DismissNotification
GetGameplayPausedNotificationEnabled
GetInsetArea
Tham Số
Lợi Nhuận
InspectPlayerFromHumanoidDescription
Lợi Nhuận
()
Mẫu mã
Mở Menu Kiểm tra với HumanoidDescription
local GuiService = game:GetService("GuiService")
local humanoidDescription = Instance.new("HumanoidDescription")
humanoidDescription.HatAccessory = "3339374070"
humanoidDescription.BackAccessory = "3339363671"
GuiService:InspectPlayerFromHumanoidDescription(humanoidDescription, "MyPlayer")InspectPlayerFromUserId
IsTenFootInterface
RemoveSelectionGroup
SendNotification
Tham Số
Lợi Nhuận
SetGameplayPausedNotificationEnabled
Sự Kiện