Classe de moteur
GuiService
*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.
Résumé
Propriétés
Méthodes
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):() |
Événements
Référence API
Propriétés
IsModalDialog
IsWindows
PreferredTextSize
Échantillons de code
Détecter/Appliquer les changements à la taille de texte préférée
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 = "Test de Label de Texte"
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 ajoute", addedTextHeight, " à la taille de texte par défaut")
textLabel.Size = UDim2.new(0, 0, 0, FONT_SIZE + addedTextHeight + PADDING)
end
applyAddedTextHeight()
GuiService:GetPropertyChangedSignal("PreferredTextSize"):Connect(applyAddedTextHeight)PreferredTransparency
Échantillons de code
Détecter/Appliquer les changements de transparence préférée
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
-- Stocker les instances initiales marquées
for _, object in CollectionService:GetTagged(TAG) do
onInstanceAdded(object)
end
-- Détecter quand une instance marquée est ajoutée ou retirée
CollectionService:GetInstanceAddedSignal(TAG):Connect(onInstanceAdded)
CollectionService:GetInstanceRemovedSignal(TAG):Connect(onInstanceRemoved)
-- Lorsque le paramètre en jeu est changé, ajuster les instances marquées
GuiService:GetPropertyChangedSignal("PreferredTransparency"):Connect(function()
for object, defaultTransparency in transparentBackObjects do
object.BackgroundTransparency = defaultTransparency * GuiService.PreferredTransparency
end
end)SelectedObject
Échantillons de code
Impression lors du changement de sélection de manette
local GuiService = game:GetService("GuiService")
local function printChanged(value)
if value == "SelectedObject" then
print("Le SelectedObject a changé !")
end
end
GuiService.Changed:Connect(printChanged)TopbarInset
Échantillons de code
Cadre réactif dans l'espace de la barre supérieure disponible
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
Échantillons de code
Modifications de la taille d'affichage du viewport
local GuiService = game:GetService("GuiService")
local function updateUI()
if (GuiService.ViewportDisplaySize == Enum.DisplaySize.Small) then
-- Mettre à jour l'interface utilisateur pour un petit écran
elseif (GuiService.ViewportDisplaySize == Enum.DisplaySize.Large) then
-- Mettre à jour l'interface utilisateur pour un grand écran
else
-- Mettre à jour l'interface utilisateur pour un écran moyen/par défaut
end
end
GuiService:GetPropertyChangedSignal("ViewportDisplaySize"):Connect(updateUI)
updateUI()Méthodes
AddSelectionParent
AddSelectionTuple
CloseInspectMenu
GuiService:CloseInspectMenu():()
Retours
()
DismissNotification
GetGameplayPausedNotificationEnabled
GetInsetArea
Paramètres
Retours
InspectPlayerFromHumanoidDescription
Retours
()
Échantillons de code
Ouvrir un menu d'inspection avec un 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
Paramètres
Retours
SetGameplayPausedNotificationEnabled
Événements