配置默认文字聊天窗口的属性。它的父辈是 TextChatService 。
概要
属性
默认聊天窗口的实际屏幕位置,以像素计算。
默认聊天窗口的实际屏幕尺寸,以像素计算。
默认聊天窗口的背景颜色。
默认聊天窗口的背景透明度。
是否显示默认聊天窗口。
用于在默认聊天窗口中渲染文本的字体。
默认聊天窗口高度应缩放的因子。
聊天窗口的横向对齐。
默认聊天窗口中文本的颜色。
默认聊天窗口中文本的大小。
默认聊天窗口中文本的字体颜色。
默认聊天窗口中文本的stroke透明度。
聊天窗口的垂直对齐。
默认聊天窗口宽度应缩放的因子。
方法
创建一个新的 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