Engine Class
GuiService
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
คุณสมบัติ
วิธีการ
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):() |
เหตุการณ์
เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
IsModalDialog
IsWindows
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
ตัวอย่างโค้ด
ตรวจจับ/ปรับเปลี่ยนการโปร่งใสที่ต้องการ
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)SelectedObject
ตัวอย่างโค้ด
การพิมพ์เมื่อการเลือก Gamepad เปลี่ยน
local GuiService = game:GetService("GuiService")
local function printChanged(value)
if value == "SelectedObject" then
print("SelectedObject ถูกเปลี่ยนแปลง!")
end
end
GuiService.Changed:Connect(printChanged)TopbarInset
ตัวอย่างโค้ด
กรอบที่ตอบสนองภายในพื้นที่แถบด้านบนที่มีอยู่
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
ตัวอย่างโค้ด
การเปลี่ยนแปลงขนาดการแสดงผลของ Viewport
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
GuiService:CloseInspectMenu():()
ส่งค่ากลับ
()
DismissNotification
GetGameplayPausedNotificationEnabled
GetInsetArea
พารามิเตอร์
ส่งค่ากลับ
InspectPlayerFromHumanoidDescription
ส่งค่ากลับ
()
ตัวอย่างโค้ด
การเปิดเมนูตรวจสอบด้วย 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
พารามิเตอร์
ส่งค่ากลับ
SetEmotesMenuOpen
SetGameplayPausedNotificationEnabled
เหตุการณ์