CREATE YOUR WORLD
Chat
Customize sending and receiving chat messages
11min
you can customize the chat messages you send and receive by importing the zepeto chat package ❗️ caution this feature is available in a world where multiplayer elements are implemented 👍 points for reference you can send/receive chat even in an editor environment only chat messages created by users through handlers can be sent/received (quick chat, system messages cannot be received) function definition class zepetochat extends system object { public static get instance() zepetochatimplementation; public static get onreceivedmessage() unityengine events unityevent$1\<imessage>; public constructor(); public static send($message string) void; } zepetochat you can use send() to send specific messages to the chat window you can use the zepetochat onreceivedmessage addlistener() to determine which event to receive the message example of use press the buttons 1 and 2 to send a specified message create a custom message in inputfield to send the message import { zepetoscriptbehaviour } from 'zepeto script'; import { button, inputfield, text } from 'unityengine ui'; import { zepetochat, messagetype, usermessage } from 'zepeto chat'; import { color } from 'unityengine'; export default class customchat extends zepetoscriptbehaviour { public custom1chatbtn button; public custom2chatbtn button; public sendchatbtn button; public resulttext text; public inputchatbox inputfield; start() { // when button click this custom1chatbtn onclick addlistener(() => { // change text color this resulttext color = color magenta; // send message zepetochat send("1"); }); this custom2chatbtn onclick addlistener(() => { this resulttext color = color blue; zepetochat send("2"); }); this sendchatbtn onclick addlistener(() => { this resulttext color = color black; const inputmsg = this inputchatbox text; zepetochat send(inputmsg); }); // receive message zepetochat onreceivedmessage addlistener(msg => { const usermsg = msg as usermessage; this resulttext text = `\[user ${usermsg username}] ${usermsg message}`; }); } } enabling/disabling the chat button feature available in a world where multiplayer elements are implemented you can check on the mobile test declarations public static setactivechatui($value boolean) void; example code press a specific button to toggle the chat button as enabled/disabled import { zepetoscriptbehaviour } from 'zepeto script'; import { button } from 'unityengine ui'; import { zepetochat, messagetype, usermessage } from 'zepeto chat'; export default class chatcontroller extends zepetoscriptbehaviour { public chatuibtn button; private ischatuiactive boolean = true; start() { // when button click this chatuibtn onclick addlistener(() => { // send message if (this ischatuiactive) { zepetochat setactivechatui(false); this ischatuiactive = false; console log("chat ui disabled"); } else { zepetochat setactivechatui(true); this ischatuiactive = true; console log("chat ui enabled"); } }); } } determining filtered messages feature available in a world where multiplayer elements are implemented you can check on the mobile test declarations public isfiltered boolean; example code determine if the received chat message is a filtered message and print it out on the screen import { zepetoscriptbehaviour } from 'zepeto script'; import { text } from 'unityengine ui'; import { zepetochat, messagetype, usermessage } from 'zepeto chat'; export default class chatcontroller extends zepetoscriptbehaviour { public filterresulttext text; start() { // receive message zepetochat onreceivedmessage addlistener(msg => { const usermsg = msg as usermessage; if (usermsg isfiltered) { this filterresulttext text = `this message has been filtered ${usermsg message}`; } else { this filterresulttext text = `this message is not filtered ${usermsg message}`; } }); } }