Creator生成的Android原生端性能拉胯,求曲线救国的方法。
做了一个测试,生成1000个预制体节点,分别加入2个节点下,每个节点放500个预制体节点。来回隐藏A,B两个节点。在H5上面性能还过得去,但是在android原生上,极为拉胯,估计切一次3秒左右。以下是视频和Demo源码。求破解方法。
-
H5视频链接:http://record-logs.oss-cn-beijing.aliyuncs.com/vcr-3.6.3-zhoushen-309359-5.mp4?t=1694431842807
-
android视频链接:https://download-1259429148.cos.ap-shanghai.myqcloud.com/video/fa47f969cc821ed08cd01a0afc759049.mp4
-
测试工程
-
CocosCheck.zip (415.6 KB)
-
测试代码:
import { Prefab } from 'cc';
import { _decorator, Component, instantiate, Node } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('testTwo')
export class testTwo extends Component {
@property({type: Node})
mainLayer: Node = null;
@property({type: Node})
gameLayer: Node = null;
@property({type: Prefab})
ts: Node = null;
@property({
type: Node,
})
btnspeed: Node = null;
isShowLeft = true;
start() {
// ZFApp.AudioManager.playMusic(MusicFilePath.MusicPath+11006);
this.addNode(this.mainLayer,true);
this.addNode(this.gameLayer,false);
this.btnChange()
}
addNode(fnode:Node,isLeft = true){
let size = 500;
for(let i=0;i<size;i++){
let node:Node = instantiate(this.ts);
let x = 0;
if(isLeft){
x = -100;
}else{
x = 100;
}
node.setPosition(x,i*2,0);
fnode.addChild(node);
}
}
btnChange(){
this.mainLayer.active = false;
this.gameLayer.active = false;
this.isShowLeft = !this.isShowLeft;
if(this.isShowLeft){
this.mainLayer.active = true;
}else{
this.gameLayer.active = true;
}
}
}
