有些Component只需要在Editor里面使用,可以在构建时去掉吗?
if (CC_EDITOR) {
// 编辑器中才生效,这一段代码在构建时将被剔除
cc.Class({
extends: cc.Component,
properties: {
location: {
default: new V2(100, 200)
}
},
update: function () {
...
},
});
}
else {
// 否则这个组件什么也不做
cc.Class({
extends: cc.Component,
start: function () {
// 在开始后就移除自己
this.destroy();
}
});
}
1赞
这样导出的json里还是有这个component。主要是想要导出过后的json小一点。