import { _decorator, AudioSource, AudioClip, Label, CCString } from "cc"; import { EDITOR } from "cc/env"; import Language from "../Language"; /**音频组件代理 */ const {ccclass, property,menu,executeInEditMode} = _decorator; @ccclass("LabelEx") @menu("扩展/文本扩展") @executeInEditMode export default class LabelEx extends Label { @property(CCString) private _original: string = ""; @property({ displayName: "多语言KEY"}) public get original(): string { return this._original; } public set original(value: string) { this._original = value; this.switchLabel(); } private switchLabel(){ if (EDITOR) { this.string = this._original; } else { this.string = Language.getValue(this._original); } } onLoad(): void { this.switchLabel(); } onFocusInEditor(){ if(EDITOR){ this.switchLabel(); } } }