PC-20230316NUNE\Administrator 8323fc141b 提交素材
2024-01-05 17:45:57 +08:00

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}`
}
}