Classe do mecanismo
GuiService
*Este conteúdo é traduzido por IA (Beta) e pode conter erros. Para ver a página em inglês, clique aqui.
Resumo
Propriedades
Métodos
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):() |
Eventos
Referência API
Propriedades
IsModalDialog
IsWindows
PreferredTextSize
Amostras de código
Detectar/Aplicar Mudanças no Tamanho de Texto Preferido
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 = "Teste de Rótulo de Texto"
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 adiciona", addedTextHeight, " ao tamanho de texto padrão")
textLabel.Size = UDim2.new(0, 0, 0, FONT_SIZE + addedTextHeight + PADDING)
end
applyAddedTextHeight()
GuiService:GetPropertyChangedSignal("PreferredTextSize"):Connect(applyAddedTextHeight)PreferredTransparency
Amostras de código
Detectar/Aplicar Mudanças na Transparência Preferida
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
-- Armazenar instâncias marcadas iniciais
for _, object in CollectionService:GetTagged(TAG) do
onInstanceAdded(object)
end
-- Detectar quando uma instância marcada é adicionada ou removida
CollectionService:GetInstanceAddedSignal(TAG):Connect(onInstanceAdded)
CollectionService:GetInstanceRemovedSignal(TAG):Connect(onInstanceRemoved)
-- Quando a configuração do jogo é alterada, ajustar as instâncias marcadas
GuiService:GetPropertyChangedSignal("PreferredTransparency"):Connect(function()
for object, defaultTransparency in transparentBackObjects do
object.BackgroundTransparency = defaultTransparency * GuiService.PreferredTransparency
end
end)SelectedObject
Amostras de código
Mudando a Seleção do Gamepad
local GuiService = game:GetService("GuiService")
local function printChanged(value)
if value == "SelectedObject" then
print("O SelectedObject mudou!")
end
end
GuiService.Changed:Connect(printChanged)TopbarInset
Amostras de código
Quadro Responsivo Dentro do Espaço Disponível na Barra Superior
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
Amostras de código
Mudanças no Tamanho da Tela do Visor
local GuiService = game:GetService("GuiService")
local function updateUI()
if (GuiService.ViewportDisplaySize == Enum.DisplaySize.Small) then
-- Atualizar UI para tela pequena
elseif (GuiService.ViewportDisplaySize == Enum.DisplaySize.Large) then
-- Atualizar UI para tela grande
else
-- Atualizar UI para tela média/padrão
end
end
GuiService:GetPropertyChangedSignal("ViewportDisplaySize"):Connect(updateUI)
updateUI()Métodos
AddSelectionParent
AddSelectionTuple
CloseInspectMenu
GuiService:CloseInspectMenu():()
Devolução
()
DismissNotification
GetGameplayPausedNotificationEnabled
GetInsetArea
Parâmetros
Devolução
InspectPlayerFromHumanoidDescription
Devolução
()
Amostras de código
Abrindo um Menu de Inspeção com uma 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
Parâmetros
Devolução
SetGameplayPausedNotificationEnabled
Eventos