Service / ChatBubble
ChatBubble Class
Chatting with bubbles above the head
- What is an overhead bubble?
The bubbles that appear above an object or character's head are usually referred to as "dialogue bubbles" or "comic bubbles". This visual effect is used to represent an object or character speaking, thinking, or conveying information.
Conversation bubbles usually contain words, icon or emoticons to convey the language, mood or intention of objects or character.
They can be presented as cloud like bubbles, rectangular bubbles, or other shapes, depending on the artistic style and design decisions of the game. (Currently, it is possible to modify bubble or text size, color, etc., but the bubble skin style function is not yet supported. In the future, the interface will be exposed for DIY bubble style.)
By using dialogue bubbles in the game, developers can more vividly show the interaction and dialogue between objects or character, and better understand the story, task prompt or character 'personality characteristics.
Table of contents
Accessors
bubbleBackgroundColor(): LinearColor |
---|
Obtain the background color of bubbles |
bubbleDisplayDistance(): number |
Obtain the distance between bubbles |
bubbleDuration(): number |
Obtain the duration of bubbles |
bubbleEnabled(): boolean |
Get the Boolean value of whether the bubble function is enabled or not. |
bubblePositionOffset(): Vector |
Get Bubble position offset |
bubbleTextColor(): LinearColor |
Get bubble text color |
bubbleTextFont(): UIFontGlyph |
Get Bubble Text Font |
bubbleTextSize(): number |
Get bubble text size |
maxParallelBubbles(): number |
Obtain the number of coexisting bubbles on the head when speaking. |
onChatBubbleDisplay(): MulticastDelegate <(message : string , parent : GameObject ) => void > |
Delegate triggered when a text is sent |
onMessageReceive(): MulticastDelegate <(mesage : string ) => void > |
Commission triggered when receiving a certain paragraph of text |
Methods
displayChatBubbble(parent : GameObject , message : string ): void other |
---|
Display bubbles |
Accessors
bubbleBackgroundColor
• | • | ||||
---|---|---|---|---|---|
Obtain the background color of bubbles Example usage: Create a script called NewScript, place it in the object bar, open the script, modify the original content to the following, save and run the game, and bubbles will appear on the top of the cube. ts
Returns
| Set bubble background color Parameters
|
bubbleDisplayDistance
• | • | ||||
---|---|---|---|---|---|
Obtain the distance between bubbles Example usage: Create a script called NewScript, place it in the object bar, open the script, modify the original content to the following, save and run the game, and bubbles will appear on the top of the cube. ts
Returns
| Set bubble spacing distance Parameters
|
bubbleDuration
• | • | ||||
---|---|---|---|---|---|
Obtain the duration of bubbles Example usage: Create a script called NewScript, place it in the object bar, open the script, modify the original content to the following, save and run the game, and bubbles will appear on the top of the cube. ts
Returns
| Set bubble duration duration Parameters
|
bubbleEnabled
• | • | ||||
---|---|---|---|---|---|
Get the Boolean value of whether the bubble function is enabled or not. Example usage: Create a script called NewScript, place it in the object bar, open the script, modify the original content to the following, save and run the game, and bubbles will appear on the top of the cube. ts
Returns
| Set whether to enable the bubble function. This is a master switch that produces a bubble effect when an object or character speaks when turned on. Parameters
|
bubblePositionOffset
• | • | ||||
---|---|---|---|---|---|
Get Bubble position offset Example usage: Create a script called NewScript, place it in the object bar, open the script, modify the original content to the following, save and run the game, and bubbles will appear on the top of the cube. ts
Returns
| Set bubble position offset Parameters
|
bubbleTextColor
• | • | ||||
---|---|---|---|---|---|
Get bubble text color Example usage: Create a script called NewScript, place it in the object bar, open the script, modify the original content to the following, save and run the game, and bubbles will appear on the top of the cube. ts
Returns
| Set bubble text color Parameters
|
bubbleTextFont
• | • | ||||
---|---|---|---|---|---|
Get Bubble Text Font Example usage: Create a script called NewScript, place it in the object bar, open the script, modify the original content to the following, save and run the game, and bubbles will appear on the top of the cube. ts
Returns
| Set Bubble Text Font Parameters
|
bubbleTextSize
• | • | ||||
---|---|---|---|---|---|
Get bubble text size Example usage: Create a script called NewScript, place it in the object bar, open the script, modify the original content to the following, save and run the game, and bubbles will appear on the top of the cube. ts
Returns
| Set bubble text size Parameters
|
maxParallelBubbles
• | • | ||||
---|---|---|---|---|---|
Obtain the number of coexisting bubbles on the head when speaking. If number=5, it means that five bubbles can exist simultaneously. By default, three bubbles coexist. Example usage: Create a script called NewScript, place it in the object bar, open the script, modify the original content to the following, save and run the game, and bubbles will appear on the top of the cube. ts
Returns
| Set the number of coexisting bubbles on the head when speaking. You can set the number of coexisting bubbles according to your preferences. Parameters
|
onChatBubbleDisplay
• | ||
---|---|---|
Delegate triggered when a text is sent Returns
|
onMessageReceive
• |
---|
Commission triggered when receiving a certain paragraph of text Returns |
MulticastDelegate <(mesage : string ) => void > |
---|
Methods
displayChatBubbble
• Static
displayChatBubbble(parent
, message
): void
other
Display bubbles
Parameters
parent GameObject | Gameobject objects mounted on bubbles |
---|---|
message string | Bubble display text range: unlimited |
Example usage: Create a script called NewScript, place it in the object bar, open the script, modify the original content to the following, save and run the game, and bubbles will appear on the top of the cube.
@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");
});
}
}