學習
引擎類別
GuiService
無法建立
服務
未複製

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡



API 參考
屬性
AutoSelectGuiEnabled
平行讀取
功能: UI, Input
GuiService.AutoSelectGuiEnabled:boolean

CoreGuiNavigationEnabled
隱藏
未複製
平行讀取
功能: UI, Input
GuiService.CoreGuiNavigationEnabled:boolean

GuiNavigationEnabled
平行讀取
功能: UI, Input
GuiService.GuiNavigationEnabled:boolean

IsModalDialog
已棄用

IsWindows
已棄用

MenuIsOpen
唯讀
未複製
平行讀取
功能: UI
GuiService.MenuIsOpen:boolean

PreferredTextSize
唯讀
未複製
平行讀取
功能: UI
GuiService.PreferredTextSize:Enum.PreferredTextSize
範例程式碼
偵測/應用偏好文字大小的變更
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 = "文字標籤測試"
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 添加了", addedTextHeight, "到默認文字大小")
textLabel.Size = UDim2.new(0, 0, 0, FONT_SIZE + addedTextHeight + PADDING)
end
applyAddedTextHeight()
GuiService:GetPropertyChangedSignal("PreferredTextSize"):Connect(applyAddedTextHeight)

PreferredTransparency
隱藏
唯讀
未複製
平行讀取
功能: UI
GuiService.PreferredTransparency:number
範例程式碼
偵測/應用偏好的透明度變更
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
-- 儲存初始的標記實例
for _, object in CollectionService:GetTagged(TAG) do
onInstanceAdded(object)
end
-- 偵測標記實例的新增或移除
CollectionService:GetInstanceAddedSignal(TAG):Connect(onInstanceAdded)
CollectionService:GetInstanceRemovedSignal(TAG):Connect(onInstanceRemoved)
-- 當遊戲中的設定變更時,調整標記實例
GuiService:GetPropertyChangedSignal("PreferredTransparency"):Connect(function()
for object, defaultTransparency in transparentBackObjects do
object.BackgroundTransparency = defaultTransparency * GuiService.PreferredTransparency
end
end)

ReducedMotionEnabled
隱藏
唯讀
未複製
平行讀取
功能: UI
GuiService.ReducedMotionEnabled:boolean

SelectedObject
平行讀取
功能: UI, Input
GuiService.SelectedObject:GuiObject
範例程式碼
當遊戲手把選擇更改時打印
local GuiService = game:GetService("GuiService")
local function printChanged(value)
if value == "SelectedObject" then
print("選擇的對象已更改!")
end
end
GuiService.Changed:Connect(printChanged)

TopbarInset
唯讀
未複製
平行讀取
功能: UI
GuiService.TopbarInset:Rect
範例程式碼
可響應的框架於可用的頂部工具條空間內
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)

TouchControlsEnabled
平行讀取
功能: UI, Input
GuiService.TouchControlsEnabled:boolean

ViewportDisplaySize
唯讀
未複製
平行讀取
功能: UI
GuiService.ViewportDisplaySize:Enum.DisplaySize
範例程式碼
視口顯示大小變更
local GuiService = game:GetService("GuiService")
local function updateUI()
if (GuiService.ViewportDisplaySize == Enum.DisplaySize.Small) then
-- 更新 UI 為小螢幕
elseif (GuiService.ViewportDisplaySize == Enum.DisplaySize.Large) then
-- 更新 UI 為大螢幕
else
-- 更新 UI 為中等/預設螢幕
end
end
GuiService:GetPropertyChangedSignal("ViewportDisplaySize"):Connect(updateUI)
updateUI()

方法
AddSelectionParent
已棄用

AddSelectionTuple
已棄用

CloseInspectMenu
功能: UI
GuiService:CloseInspectMenu():()
返回
()

DismissNotification
功能: UI
GuiService:DismissNotification(notificationId:string):boolean
參數
notificationId:string
返回

GetEmotesMenuOpen
功能: UI
GuiService:GetEmotesMenuOpen():boolean
返回

GetGameplayPausedNotificationEnabled
功能: UI
GuiService:GetGameplayPausedNotificationEnabled():boolean
返回

GetGuiInset
功能: UI
GuiService:GetGuiInset():Tuple
返回

GetInsetArea
功能: UI
GuiService:GetInsetArea(screenInsets:Enum.ScreenInsets):Rect
參數
screenInsets:Enum.ScreenInsets
返回

GetInspectMenuEnabled
功能: UI
GuiService:GetInspectMenuEnabled():boolean
返回

InspectPlayerFromHumanoidDescription
功能: UI, AvatarAppearance
GuiService:InspectPlayerFromHumanoidDescription(
humanoidDescription:Instance, name:string
):()
參數
humanoidDescription:Instance
name:string
返回
()
範例程式碼
使用 HumanoidDescription 開啟檢查菜單
local GuiService = game:GetService("GuiService")
local humanoidDescription = Instance.new("HumanoidDescription")
humanoidDescription.HatAccessory = "3339374070"
humanoidDescription.BackAccessory = "3339363671"
GuiService:InspectPlayerFromHumanoidDescription(humanoidDescription, "MyPlayer")

InspectPlayerFromUserId
功能: UI, AvatarAppearance
GuiService:InspectPlayerFromUserId(userId:User):()
參數
userId:User
返回
()
範例程式碼
打開用戶 ID 的檢查菜單
-- 獲取 GuiService
local GuiService = game:GetService("GuiService")
-- 使用用戶 ID 檢查玩家
GuiService:InspectPlayerFromUserId(772462)

IsTenFootInterface
已棄用

RemoveSelectionGroup
已棄用

Select
功能: UI
GuiService:Select(selectionParent:Instance):()
參數
selectionParent:Instance
返回
()

SendNotification
功能: UI
GuiService:SendNotification(notificationInfo:Dictionary):string
參數
notificationInfo:Dictionary
返回

SetEmotesMenuOpen
功能: UI
GuiService:SetEmotesMenuOpen(isOpen:boolean):()
參數
isOpen:boolean
返回
()

SetGameplayPausedNotificationEnabled
功能: UI
GuiService:SetGameplayPausedNotificationEnabled(enabled:boolean):()
參數
enabled:boolean
返回
()

SetInspectMenuEnabled
功能: UI
GuiService:SetInspectMenuEnabled(enabled:boolean):()
參數
enabled:boolean
返回
()

活動
MenuClosed
功能: UI
GuiService.MenuClosed():RBXScriptSignal

MenuOpened
功能: UI
GuiService.MenuOpened():RBXScriptSignal

©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。