Files
dgflash 2acc9bd7e8 修复提示系统加载与 RichText 兼容问题
1. 统一提示预制路径为 UI_Notify/UI_Wait/UI_Mask
2. LayerNotify 统一异步加载并支持模板克隆
3. LanguageLabel 兼容 RichText 模块未启用场景
2026-06-19 13:26:40 +08:00

44 lines
1.2 KiB
TypeScript

import { Animation, Component, Label, _decorator } from 'cc';
import { LanguageLabel } from '../../../libs/gui/language/LanguageLabel';
const { ccclass, property } = _decorator;
/** 滚动消息提示组件 */
@ccclass('Notify')
export class Notify extends Component {
@property(Label)
private lab_content: Label = null!;
@property(Animation)
private animation: Animation = null!;
/** 提示动画完成 */
onComplete: Function = null!;
onLoad() {
this.animation.on(Animation.EventType.FINISHED, this.onFinished, this);
}
private onFinished() {
this.node.parent!.destroy();
this.onComplete && this.onComplete();
this.onComplete = null!;
}
/**
* 显示提示
* @param msg 文本
* @param useI18n 设置为 true 时,使用多语言功能 msg 参数为多语言 key
*/
toast(msg: string, useI18n: boolean) {
const label = this.lab_content.getComponent(LanguageLabel)!;
if (useI18n) {
label.enabled = true;
label.dataID = msg;
} else {
label.enabled = false;
this.lab_content.string = msg;
}
}
}