服务 / ChatBubble
ChatBubble Class
聊天头顶气泡
- 什么是头顶气泡?
物体或角色头顶上出现的气泡通常称为「对话气泡」或「漫画气泡」。这种视觉效果被用来表示物体或角色正在说话、思考或传达信息。
对话气泡通常包含文字、图标或表情符号,以传达物体或角色的语言、情绪或意图。
它们可以呈现为云状气泡,矩形气泡或其他形状,具体样式根据游戏的艺术风格和设计决策而定。(目前可以修改气泡或文字大小颜色等,暂未支持气泡皮肤样式功能,之后会暴露接口DIY气泡样式)
通过在游戏中使用对话气泡,开发者可以更生动地展示物体或角色之间的交互和对话,更好地理解故事情节、任务提示或角色的个性特点。
Table of contents
Accessors
bubbleBackgroundColor(): LinearColor |
---|
获取气泡背景颜色 |
bubbleDisplayDistance(): number |
获取气泡间隔距离 |
bubbleDuration(): number |
获取气泡持续时长 |
bubbleEnabled(): boolean |
获取是否开启气泡功能的布尔值。 |
bubblePositionOffset(): Vector |
获取气泡位置偏移 |
bubbleTextColor(): LinearColor |
获取气泡文字颜色 |
bubbleTextFont(): UIFontGlyph |
获取气泡文字字体 |
bubbleTextSize(): number |
获取气泡文字大小 |
maxParallelBubbles(): number |
获取说话时头顶气泡共存数量。 |
onChatBubbleDisplay(): MulticastDelegate <(message : string , parent : GameObject ) => void > |
当发出某一段文字时触发的委托 |
onMessageReceive(): MulticastDelegate <(mesage : string ) => void > |
当收到某一段文字时触发的委托 |
Methods
displayChatBubbble(parent : GameObject , message : string ): void |
---|
显示气泡 |
Accessors
bubbleBackgroundColor
• | • | ||||
---|---|---|---|---|---|
获取气泡背景颜色 Returns
| 设置气泡背景颜色 Parameters
|
ts
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleBackgroundColor = LinearColor.green;
});
}
}
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleBackgroundColor = LinearColor.green;
});
}
}
bubbleDisplayDistance
• | • | ||||
---|---|---|---|---|---|
获取气泡间隔距离 Returns
| 设置气泡间隔距离 Parameters
|
ts
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleDisplayDistance = 100;
});
}
}
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleDisplayDistance = 100;
});
}
}
bubbleDuration
• | • | ||||
---|---|---|---|---|---|
获取气泡持续时长 Returns
| 设置气泡持续时长 Parameters
|
ts
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleDuration = 1;
});
}
}
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleDuration = 1;
});
}
}
bubbleEnabled
• | • | ||||
---|---|---|---|---|---|
获取是否开启气泡功能的布尔值。 Returns
| 设置是否开启气泡功能。 这是一个总开关,当开启时,物体或者角色说话时才会有气泡效果。 Parameters
|
ts
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleEnabled = true;
});
}
}
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleEnabled = true;
});
}
}
bubblePositionOffset
• | • | ||||
---|---|---|---|---|---|
获取气泡位置偏移 Returns
| 设置气泡位置偏移 Parameters
|
ts
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubblePositionOffset = new Vector(0,0,50);
});
}
}
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubblePositionOffset = new Vector(0,0,50);
});
}
}
bubbleTextColor
• | • | ||||
---|---|---|---|---|---|
获取气泡文字颜色 Returns
| 设置气泡文字颜色 Parameters
|
ts
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleTextColor = LinearColor.red;
});
}
}
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleTextColor = LinearColor.red;
});
}
}
bubbleTextFont
• | • | ||||
---|---|---|---|---|---|
获取气泡文字字体 Returns
| 设置气泡文字字体 Parameters
|
ts
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleTextFont = UIFontGlyph.BoldItalics;
});
}
}
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleTextFont = UIFontGlyph.BoldItalics;
});
}
}
bubbleTextSize
• | • | ||||
---|---|---|---|---|---|
获取气泡文字大小 Returns
| 设置气泡文字大小 Parameters
|
ts
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleTextSize = 30;
});
}
}
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.bubbleTextSize = 30;
});
}
}
maxParallelBubbles
• | • | ||||
---|---|---|---|---|---|
获取说话时头顶气泡共存数量。 如果number=5,意味着可以同时存在五个气泡。 默认是三个气泡共存。 Returns
| 设置说话时头顶气泡共存数量。 可以根据自己的喜好设置气泡共存数量。 Parameters
|
ts
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.maxParallelBubbles = 1;
});
}
}
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
ChatBubble.maxParallelBubbles = 1;
});
}
}
onChatBubbleDisplay
• | ||
---|---|---|
当发出某一段文字时触发的委托 Returns
|
onMessageReceive
• |
---|
当收到某一段文字时触发的委托 Returns |
MulticastDelegate <(mesage : string ) => void > |
---|
Methods
displayChatBubbble
• Static
displayChatBubbble(parent
, message
): void
显示气泡
Parameters
parent GameObject | 气泡挂载的 gameobject 物体 |
---|---|
message string | 气泡显示的文字 range: 不限制 |
ts
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
let cube = GameObject.asyncFindGameObjectById("0AB6A7D9");
ChatBubble.displayChatBubbble(await cube, "hello");
});
}
}
@Component
export default class NewScript extends Script {
protected onStart(): void {
if(SystemUtil.isClient()){
UIService.show(newUI);
}
}
}
class newUI extends UIScript{
button:StaleButton;
protected onStart() {
this.canUpdate = false;
this.layer = UILayerScene;
this.button = StaleButton.newObject(this.rootCanvas);
this.button.text = "button";
this.button.visibility = SlateVisibility.Visible;
this.button.onClicked.add(async ()=>{
let cube = GameObject.asyncFindGameObjectById("0AB6A7D9");
ChatBubble.displayChatBubbble(await cube, "hello");
});
}
}