エンジンクラス
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
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
パラメータ
戻り値
SetGameplayPausedNotificationEnabled
イベント