对象池小问题
在不需要的时候放入对象池 this.NodePool.put(node)
不要在创建完成时放入对象池,否则会出现第一次无法回收的bug
//创建eggUI
createEggUI() {
let node = null;
if (this.eggUINodePool.size() > 0) {
//节点池有就用节点池
node = this.eggUINodePool.get();
node.parent = this.UINodeGroup;
node.getComponent("eggUI").iniNode();
} else {
//动态加载
cc.loader.loadRes("prefabs/UI/eggUI", cc.Prefab, (err, res) => {
node = cc.instantiate(res);
node.parent = this.UINodeGroup;
node.getComponent("eggUI").iniNode();
})
};
},