[LayaAir 2.0]关于get/set重写问题

1.x中使用方法Laya.getset,2.x中应该使用哪个方法呢
static getset(isStatic:Boolean, target:any, name:String, getter:Function, setter:Function):void;
已邀请:

Nikeo

赞同来自:

通过查看底层源码,2.x以后支持覆盖类的写法:
1. 使用自定类进行覆盖目标类,在自定义类中重写一切方法。
2. 对于引擎类,如果引擎升级后只需在自定义类中修改升级即可,维护比较方便。
 
覆盖引擎类:
Laya.ClassUtils.regClass("Laya.Image", CustomImage);
Laya.ClassUtils.regClass("laya.ui.Image", CustomImage);
自定义类:
export class CustomImage extends Laya.Image {
set skin(value: string) {
//....重写方法体
}
}

要回复问题请先

商务合作
商务合作