ChatWindowConfiguration

顯示已棄用項目

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

無法建立

配置默認文字聊天窗口的屬性。它與 TextChatService 相關。

概要

屬性

屬性

AbsolutePosition

唯讀
未複製

只讀屬性,提供預設聊天窗口的畫面位置以像素。與 GuiBase2d.AbsolutePosition 相似。

AbsoluteSize

唯讀
未複製

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

BackgroundColor3

平行讀取

預設聊天窗口的背景顏色。如果背景顏色未被覆蓋,此值會尊重使用者的 GuiService.PreferredTransparency ,使菜單變得更灰,因為菜單透明度降低。預設值是 Color3.new(25, 27, 29)

BackgroundTransparency

平行讀取

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

Enabled

平行讀取

是否要顯示預設聊天窗口。設為 false 以隱藏。

FontFace

平行讀取

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

HeightScale

平行讀取

默认聊天窗口高度應該縮放的因子。必須是 0.52 之間的值。定義超出範圍的值會將實際值捆綁到最接近的限制。

HorizontalAlignment

聊天窗口的水平對齊。行為類似於 UIGridStyleLayout.HorizontalAlignment 。設置為 LeftRight 添加一小段距離離開觸碰相應的水平邊緣的屏幕。設置為 Center 將窗口調整到屏幕中央的水平位置。預設值是 Left

TextColor3

平行讀取

預設聊天視窗中的文字顏色。預設值為 Color3.new(255, 255, 255)

TextSize

平行讀取

預設聊天視窗中的文字大小。預設值為 14

TextStrokeColor3

平行讀取

預設聊天視窗中文字行的顏色。預設值為 Color3.new(0, 0, 0)

TextStrokeTransparency

平行讀取

預設聊天視窗中文字行的透明度。預設值為 0.5

VerticalAlignment

聊天窗口垂直對齊。行為類似於 UIGridStyleLayout.VerticalAlignment 。將設置為 TopBottom 會添加一小段距離離開觸碰相應屏幕邊緣。設置為 Center 將窗口調整到屏幕垂直中央。預設值是 Top

WidthScale

平行讀取

默认聊天窗口寬度應該縮放的因子。必須是 0.52 之間的值。定義超出範圍的值會將實際值捆綁到最接近的限制。

方法

DeriveNewMessageProperties

創建一個新的 ChatWindowMessageProperties 實例,可用於自定义聊天窗口中的訊息外觀。ChatWindowMessagePropertiesTextChatMessageProperties 中繼承。

這是用於在自定义 TextChatService.OnChatWindowAdded 回呼期間使用的。


local TextChatService = game:GetService("TextChatService")
local ChatWindowConfiguration = TextChatService.ChatWindowConfiguration
TextChatService.OnChatWindowAdded = function(textChatMessage)
local properties = ChatWindowConfiguration:DeriveNewMessageProperties()
if textChatMessage.Metadata == "Important" then
properties.TextColor3 = Color3.fromRGB(255, 0, 0)
end
return properties
end

返回

範例程式碼

This example checks if two users can chat, creates a new TextChannel, and adds them to it.

CanUsersDirectChatAsync

local TextChatService = game:GetService("TextChatService")
local directChatParticipants = TextChatService:CanUsersDirectChatAsync(userId1, { userId2 })
-- Check for eligible participants
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("Could not create TextChannel. Not enough eligible users.")
return nil

活動