mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 19:34:47 +00:00
29 lines
681 B
TypeScript
29 lines
681 B
TypeScript
import { _decorator, Component, Node } from 'cc';
|
|
import ChatData from '../../../data/ChatData';
|
|
import { GUIChatMessageDTO } from '../../../consts/GActionType';
|
|
import { Label } from 'cc';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('MainChatIcon')
|
|
export class MainChatIcon extends Component {
|
|
|
|
@property(Label)
|
|
text:Label;
|
|
|
|
onLoad(){
|
|
//监听消息
|
|
ChatData.getIns().on(this.onMessage.bind(this),this);
|
|
}
|
|
|
|
protected onDestroy(): void {
|
|
ChatData.getIns().off(this.onMessage.bind(this),this);
|
|
}
|
|
|
|
onMessage(info:GUIChatMessageDTO){
|
|
this.text.string = `${info.playerName} : ${info.message.message}`
|
|
}
|
|
|
|
}
|
|
|
|
|