-
Creator 版本:
-
目标平台:
-
详细报错信息,包含调用堆栈:
-
重现方式:
-
之前哪个版本是正常的 :
-
手机型号 :
-
手机浏览器 :
-
编辑器操作系统 :
-
编辑器之前是否有其它报错 :
-
出现概率:
-
额外线索:
需求是在inspector面板上展示类中的变量,并且在面板上修改之后再界面中能够用代码展示变量的变化。但是cc.Size设置set get时无法实现。下面是正常和出错代码
// 正常
@property({
type: cc.Enum(horizontalIncreaseDir),
tooltip: “水平排列增长方向”
})
public get xIncrease() {
return this._xIncrease;
}
public set xIncrease(v: horizontalIncreaseDir) {
this._xIncrease = v;
if (CC_EDITOR == true) {
this.reorderItems();
} else {
}
}
_xIncrease: horizontalIncreaseDir = horizontalIncreaseDir.left_to_right;
// 出错
@property({
tooltip: “手动设置固定的子节点大小”,
visible: function () { return this.needAutoCalcuItemSize == false },
})
public get customItemSize() {
cc.log(’???’);
return this._customItemSize;
}
public set customItemSize(v) {
this._customItemSize = v;
}
_customItemSize: cc.Size = new cc.Size(0, 0);
报错的原因是重复调用了getset,到时堆栈耗尽;
简单的将我想实现cc.Layout中的grid里面的改变cellsize的设置,立即就在编辑状态的游戏界面体现修改。