ScreenGui

ScreenGui 是 Roblox 中用於在玩家屏幕上顯示 2D 用戶介面元素的容器。它提供了基本的控制和信息。

** 必須附加到 PlayerGui 才能可見。使用 StarterGui 確保其在玩家加入時克隆到每個玩家的 PlayerGui 中。
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = game.Players.LocalPlayer: WaitForChild("PlayerGui")

ScreenGui 屬性

TypesDetails
ClipToDeviceSafeArea將內容裁剪到設備的安全區域。
DisplayOrder控制 ScreenGuis 的 Z-索引順序,值越大渲染越靠上。
IgnoreGuiInset決定 ScreenGui 是否會溢出到 Roblox 的核心 UI 元素中。
ScreenInsets定義屏幕上的顯示區域。

CoreUISafeInsets (核心 UI 安全區域)

CoreUISafeInsets將 UI 元素保持在核心 UI 安全區域內,避免頂欄按鈕和屏幕切口(預設)。
None沒有安全區域限制;UI 元素可能會被核心 UI 或設備切口遮擋,適用於非互動內容。
TopbarSafeInsets確保 UI 元素保持在最左側的 Roblox 控件和設備安全區域之間,動態調整以避免碰撞。
DeviceSafeInsets為整個設備的安全區域應用內邊距,避免任何屏幕切口或凹槽。
Image 1
Roblox Studio
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "Display_CoreUISafeInsets"
screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
screenGui.ScreenInsets = Enum.ScreenInsets.CoreUISafeInsets

local frame = Instance.new("Frame")
frame.Size = UDim2.new(1, 0, 1, 0)
frame.Position = UDim2.new(0, 0, 0, 0)
frame.BackgroundTransparency = 0.5
frame.BackgroundColor3 = Color3.fromRGB(255, 0, 0)  -- Red for CoreUISafeInsets
frame.Parent = screenGui

local label = Instance.new("TextLabel")
label.Text = "CoreUISafeInsets"
label.BackgroundTransparency = 0
label.BackgroundColor3 = Color3.fromRGB(255, 255, 255)  -- White background
label.TextColor3 = Color3.fromRGB(0, 0, 0)  -- Black text
label.Size = UDim2.new(0.3, 0, 0.1, 0)
label.Position = UDim2.new(0.35, 0, 0.45, 0)
label.Parent = frame
Image 1
Roblox Studio
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "Display_None"
screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
screenGui.ScreenInsets = Enum.ScreenInsets.None

local frame = Instance.new("Frame")
frame.Size = UDim2.new(1, 0, 1, 0)
frame.Position = UDim2.new(0, 0, 0, 0)
frame.BackgroundTransparency = 0.5
frame.BackgroundColor3 = Color3.fromRGB(0, 255, 0)  -- Green for None
frame.Parent = screenGui

local label = Instance.new("TextLabel")
label.Text = "None"
label.BackgroundTransparency = 0
label.BackgroundColor3 = Color3.fromRGB(255, 255, 255)  -- White background
label.TextColor3 = Color3.fromRGB(0, 0, 0)  -- Black text
label.Size = UDim2.new(0.3, 0, 0.1, 0)
label.Position = UDim2.new(0.35, 0, 0.45, 0)
label.Parent = frame
Image 1
Roblox Studio
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "Display_TopbarSafeInsets"
screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
screenGui.ScreenInsets = Enum.ScreenInsets.TopbarSafeInsets

local frame = Instance.new("Frame")
frame.Size = UDim2.new(1, 0, 1, 0)
frame.Position = UDim2.new(0, 0, 0, 0)
frame.BackgroundTransparency = 0.5
frame.BackgroundColor3 = Color3.fromRGB(0, 0, 255)  -- Blue for TopbarSafeInsets
frame.Parent = screenGui

local label = Instance.new("TextLabel")
label.Text = "TopbarSafeInsets"
label.BackgroundTransparency = 0
label.BackgroundColor3 = Color3.fromRGB(255, 255, 255)  -- White background
label.TextColor3 = Color3.fromRGB(0, 0, 0)  -- Black text
label.Size = UDim2.new(0.3, 0, 0.1, 0)
label.Position = UDim2.new(0.35, 0, 0.45, 0)
label.Parent = frame
Image 1
Roblox Studio
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "Display_DeviceSafeInsets"
screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
screenGui.ScreenInsets = Enum.ScreenInsets.DeviceSafeInsets

local frame = Instance.new("Frame")
frame.Size = UDim2.new(1, 0, 1, 0)
frame.Position = UDim2.new(0, 0, 0, 0)
frame.BackgroundTransparency = 0.5
frame.BackgroundColor3 = Color3.fromRGB(255, 255, 0)  -- Yellow for DeviceSafeInsets
frame.Parent = screenGui

local label = Instance.new("TextLabel")
label.Text = "DeviceSafeInsets"
label.BackgroundTransparency = 0
label.BackgroundColor3 = Color3.fromRGB(255, 255, 255)  -- White background
label.TextColor3 = Color3.fromRGB(0, 0, 0)  -- Black text
label.Size = UDim2.new(0.3, 0, 0.1, 0)
label.Position = UDim2.new(0.35, 0, 0.45, 0)
label.Parent = frame

如果你覺得這個教程對你有幫助,並且願意支持我的工作,請考慮請我飲杯咖啡。

非常感謝你的支持!

請我飲杯咖啡