エンジンクラス
GuiService
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
プロパティ
方法
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
コードサンプル
ゲームパッドの選択が変更されたときの印刷
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
コードサンプル
ビューポート表示サイズの変更
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
GetGuiInset
GetInsetArea
パラメータ
戻り値
コードサンプル
インセットエリアを取得
local GuiService = game:GetService("GuiService")
local noneRect = GuiService:GetInsetArea(Enum.ScreenInsets.None)
print(noneRect) --> -59, -58, 792, 334
local deviceSafeRect = GuiService:GetInsetArea(Enum.ScreenInsets.DeviceSafeInsets)
print(deviceSafeRect) --> 0, -58, 733, 313
local coreUISafeRect = GuiService:GetInsetArea(Enum.ScreenInsets.CoreUISafeInsets)
print(coreUISafeRect) --> 0, 0, 733, 313
local topbarSafeRect = GuiService:GetInsetArea(Enum.ScreenInsets.TopbarSafeInsets)
print(topbarSafeRect) --> 164, -58, 733, 0InspectPlayerFromHumanoidDescription
戻り値
()
コードサンプル
ヒューマノイド記述を使ったインスペクトメニューの表示
local GuiService = game:GetService("GuiService")
local humanoidDescription = Instance.new("HumanoidDescription")
humanoidDescription.HatAccessory = "3339374070"
humanoidDescription.BackAccessory = "3339363671"
GuiService:InspectPlayerFromHumanoidDescription(humanoidDescription, "MyPlayer")InspectPlayerFromUserId
IsTenFootInterface
RemoveSelectionGroup
SendNotification
パラメータ
戻り値
SetGameplayPausedNotificationEnabled
イベント