ChatInputBarConfiguration

顯示已棄用項目

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

無法建立

配置默認文字聊天輸入欄的屬性。它與 TextChatService 相關。

概要

屬性

屬性

AbsolutePosition

唯讀
未複製

只讀屬性,提供預設聊天輸入欄的畫面位置以像素。行為與 GuiBase2d.AbsolutePosition 相似。

AbsoluteSize

唯讀
未複製

只讀屬性,提供預設聊天輸入欄的畫面尺寸以像素。與 GuiBase2d.AbsoluteSize 相似。

AutocompleteEnabled

平行讀取

是否啟用聊天輸入欄的自動完成。設為 false 以禁用自動完成。

BackgroundColor3

平行讀取

預設聊天輸入欄的背景顏色。默认值為 Color3.new(25, 27, 29)

BackgroundTransparency

平行讀取

預設聊天輸入欄的背景透明度為 01 之間的數字。此值與使用者的 GuiService.PreferredTransparency 乘以以創建聊天輸入欄使用的有效背景透明度,可能比此值在這裡設置的更不透明。預設值是 0.2

Enabled

平行讀取

是否顯示預設聊天輸入欄。設為 false 以隱藏。

FontFace

平行讀取

用於在預設聊天輸入欄中渲染文字的字體。默認值為 Enum.Font.BuilderSansMedium

IsFocused

唯讀
未複製

指示是否將預設聊天輸入欄聚焦或否。用於發射變更的屬性事件,因此您可以實現回應輸入欄焦點狀態的回呼功能。

範例程式碼

The code below includes a simple way to create a typing indicator bubble above a user's avatar when the user is typing. Paste into a LocalScript.

Typing Indicator Bubble

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()
-- Set up 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
-- Parent a UICorner to the TextLabel to have rounded corners
local uiCorner = Instance.new("UICorner")
uiCorner.CornerRadius = UDim.new(0, 12)
uiCorner.Parent = textLabel
-- Set up 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()
-- Enable the typing indicator when the input bar is focused and disable otherwise
typingIndicatorBillboard.Enabled = ChatInputBarConfiguration.IsFocused
end)

KeyboardKeyCode

平行讀取

額外的關鍵使用者可以按下以啟動對預設聊天輸入欄的焦點。當您想要額外於 / 鍵以進行聚焦時,會很有用。

PlaceholderColor3

平行讀取

預留位置文字的顏色在預設聊天輸入欄中。預設值為 Color3.new(178, 178, 178)

TargetTextChannel

平行讀取

決定使用哪個 TextChannel 當使用者使用預設聊天輸入欄發送訊息時。

TextBox

平行讀取

指向指定的 TextBox 實例,該實例代表使用者發送訊息。您可以使用它來自由操控外觀、位置和布局,將自訂聊天輸入欄介面整合到您的體驗中,進一步提升體驗品質。當選擇將此屬性設為自訂 TextBox 時,您不需要寫任何代碼來實現以下行為:

為了安全,當提升到 ChatInputBarConfiguration.TextBox 時,對 TextBox 會有一些限制。 Luau 代碼將無法:

TextColor3

平行讀取

預設聊天輸入欄的文字顏色。預設值為 Color3.new(255, 255, 255)

TextSize

平行讀取

預設聊天輸入欄的文字大小。預設值為 14

TextStrokeColor3

平行讀取

預設聊天輸入欄中文字的筆色。預設值為 Color3.new(0, 0, 0)

TextStrokeTransparency

平行讀取

預設聊天輸入欄中文字的筆跡透明度。預設值為 0.5

方法

活動