You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
964 B
37 lines
964 B
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();
|
|
}
|
|
}
|
|
|
|
}
|