配置默認文字聊天窗口的屬性。它與 TextChatService 相關。
概要
屬性
預設聊天視窗的實際畫面位置,以畫素為單位。
預設聊天視窗的實際畫面尺寸,以畫素計算。
預設聊天窗口的背景顏色。
預設聊天窗口的背景透明度。
是否顯示預設聊天窗口。
用於在預設聊天視窗中渲染文字的字體。
默认聊天窗口高度應該縮放的因子。
聊天窗口的水平對齊。
預設聊天視窗中文字的顏色。
預設聊天視窗中文字的大小。
預設聊天視窗中文字行的顏色。
預設聊天視窗中文字的筆跡透明度。
聊天窗口垂直對齊。
默认聊天窗口寬度應該縮放的因子。
方法
創建一個新的 ChatWindowMessageProperties 實例,可用於自定义聊天窗口中的訊息外觀。
屬性
BackgroundColor3
預設聊天窗口的背景顏色。如果背景顏色未被覆蓋,此值會尊重使用者的 GuiService.PreferredTransparency ,使菜單變得更灰,因為菜單透明度降低。預設值是 Color3.new(25, 27, 29) 。
BackgroundTransparency
預設聊天窗口的背景透明度為 0 和 1 之間的數字。此值與使用者的 GuiService.PreferredTransparency 乘以以創建聊天窗口使用的有效背景透明度,可能比此值在這裡設置的更不透明。預設值是 0.3 。
HorizontalAlignment
聊天窗口的水平對齊。行為類似於 UIGridStyleLayout.HorizontalAlignment 。設置為 Left 或 Right 添加一小段距離離開觸碰相應的水平邊緣的屏幕。設置為 Center 將窗口調整到屏幕中央的水平位置。預設值是 Left 。
VerticalAlignment
聊天窗口垂直對齊。行為類似於 UIGridStyleLayout.VerticalAlignment 。將設置為 Top 或 Bottom 會添加一小段距離離開觸碰相應屏幕邊緣。設置為 Center 將窗口調整到屏幕垂直中央。預設值是 Top 。
方法
DeriveNewMessageProperties
創建一個新的 ChatWindowMessageProperties 實例,可用於自定义聊天窗口中的訊息外觀。ChatWindowMessageProperties 從 TextChatMessageProperties 中繼承。
這是用於在自定义 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.
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