學習
引擎類別
ChatWindowConfiguration
無法建立

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡


範例程式碼
獲取總聊天 UI 邊界
local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local windowConfig = TextChatService.ChatWindowConfiguration
local inputBarConfig = TextChatService.ChatInputBarConfiguration
local function getTotalChatBounds()
local windowPos = windowConfig.AbsolutePosition
local windowSize = windowConfig.AbsoluteSize
local inputPos = inputBarConfig.AbsolutePosition
local inputSize = inputBarConfig.AbsoluteSize
-- 計算兩個矩形的聯集以獲得總聊天 UI 邊界。
-- 報告的值不包括聊天窗口上下邊緣的裝飾斜角。
local topLeft = Vector2.new(
math.min(windowPos.X, inputPos.X),
math.min(windowPos.Y, inputPos.Y)
)
local bottomRight = Vector2.new(
math.max(windowPos.X + windowSize.X, inputPos.X + inputSize.X),
math.max(windowPos.Y + windowSize.Y, inputPos.Y + inputSize.Y)
)
return topLeft, bottomRight - topLeft
end
-- 等待聊天 UI 初始化並報告絕對值
task.wait(2)
local position, size = getTotalChatBounds()
print("總聊天 UI 位置:", position)
print("總聊天 UI 大小:", size)
-- 繪製一個半透明框架以視覺化邊界
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "ChatBoundsDebug"
screenGui.DisplayOrder = 100
screenGui.Parent = playerGui
local frame = Instance.new("Frame")
frame.Position = UDim2.fromOffset(position.X, position.Y)
frame.Size = UDim2.fromOffset(size.X, size.Y)
frame.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
frame.BackgroundTransparency = 0.5
frame.BorderSizePixel = 2
frame.BorderColor3 = Color3.fromRGB(255, 0, 0)
frame.Parent = screenGui

API 參考
屬性
AbsolutePosition
唯讀
未複製
功能: Chat
ChatWindowConfiguration.AbsolutePosition:Vector2

AbsoluteSize
唯讀
未複製
功能: Chat
ChatWindowConfiguration.AbsoluteSize:Vector2

BackgroundColor3
平行讀取
功能: Chat
ChatWindowConfiguration.BackgroundColor3:Color3

BackgroundTransparency
平行讀取
功能: Chat
ChatWindowConfiguration.BackgroundTransparency:number

Enabled
平行讀取
功能: Chat
ChatWindowConfiguration.Enabled:boolean

FontFace
平行讀取
功能: Chat
ChatWindowConfiguration.FontFace:Font

HeightScale
平行讀取
功能: Chat
ChatWindowConfiguration.HeightScale:number

HorizontalAlignment
功能: Chat
ChatWindowConfiguration.HorizontalAlignment:Enum.HorizontalAlignment

TextColor3
平行讀取
功能: Chat
ChatWindowConfiguration.TextColor3:Color3

TextSize
平行讀取
功能: Chat
ChatWindowConfiguration.TextSize:number

TextStrokeColor3
平行讀取
功能: Chat
ChatWindowConfiguration.TextStrokeColor3:Color3

TextStrokeTransparency
平行讀取
功能: Chat
ChatWindowConfiguration.TextStrokeTransparency:number

VerticalAlignment
功能: Chat
ChatWindowConfiguration.VerticalAlignment:Enum.VerticalAlignment

WidthScale
平行讀取
功能: Chat
ChatWindowConfiguration.WidthScale:number

方法
DeriveNewMessageProperties
功能: Chat
ChatWindowConfiguration:DeriveNewMessageProperties():ChatWindowMessageProperties
範例程式碼
兩位使用者可以直接聊天的非同步檢查
local TextChatService = game:GetService("TextChatService")
local directChatParticipants = TextChatService:CanUsersDirectChatAsync(userId1, { userId2 })
-- 檢查 是否有合格的參與者
if #directChatParticipants > 0 then
local directChannel = Instance.new("TextChannel")
directChannel.Parent = TextChatService
for _, participant in directChatParticipants do
directChannel:AddUserAsync(participant)
end
return directChannel
end
warn("無法創建 TextChannel。可用使用者不足。")
return nil

©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。