學習
引擎類別
ChatInputBarConfiguration
無法建立

*此內容是使用 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
ChatInputBarConfiguration.AbsolutePosition:Vector2

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

AutocompleteEnabled
平行讀取
功能: Chat
ChatInputBarConfiguration.AutocompleteEnabled:boolean

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

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

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

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

IsFocused
唯讀
未複製
功能: Chat
ChatInputBarConfiguration.IsFocused:boolean
範例程式碼
打字指示氣泡
local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")
local ChatInputBarConfiguration = TextChatService:FindFirstChildOfClass("ChatInputBarConfiguration")
local BubbleChatConfiguration = TextChatService:FindFirstChildOfClass("BubbleChatConfiguration")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
-- 設置 TextLabel
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.fromScale(1, 1)
textLabel.Text = ". . ."
textLabel.BackgroundColor3 = BubbleChatConfiguration.BackgroundColor3
textLabel.BorderColor3 = BubbleChatConfiguration.BackgroundColor3
textLabel.BackgroundTransparency = BubbleChatConfiguration.BackgroundTransparency
textLabel.TextColor3 = BubbleChatConfiguration.TextColor3
textLabel.FontFace = BubbleChatConfiguration.FontFace
textLabel.TextSize = BubbleChatConfiguration.TextSize
-- 將 UICorner 作為 TextLabel 的父級,以便有圓角
local uiCorner = Instance.new("UICorner")
uiCorner.CornerRadius = UDim.new(0, 12)
uiCorner.Parent = textLabel
-- 設置 Billboard
local typingIndicatorBillboard = Instance.new("BillboardGui")
typingIndicatorBillboard.Enabled = false
typingIndicatorBillboard.Size = UDim2.fromScale(1, 1)
typingIndicatorBillboard.StudsOffsetWorldSpace = Vector3.new(-0, 4, 0)
typingIndicatorBillboard.Adornee = Character
textLabel.Parent = typingIndicatorBillboard
typingIndicatorBillboard.Parent = LocalPlayer:FindFirstChildOfClass("PlayerGui")
ChatInputBarConfiguration:GetPropertyChangedSignal("IsFocused"):Connect(function()
-- 當輸入條聚焦時啟用打字指示器,否則禁用
typingIndicatorBillboard.Enabled = ChatInputBarConfiguration.IsFocused
end)

KeyboardKeyCode
平行讀取
功能: Chat
ChatInputBarConfiguration.KeyboardKeyCode:Enum.KeyCode

PlaceholderColor3
平行讀取
功能: Chat
ChatInputBarConfiguration.PlaceholderColor3:Color3

TargetTextChannel
平行讀取
功能: Chat
ChatInputBarConfiguration.TargetTextChannel:TextChannel

TextBox
平行讀取
功能: Chat
ChatInputBarConfiguration.TextBox:TextBox

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

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

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

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

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