Creator生成的Android原生端性能拉胯,求曲线救国的方法

Creator生成的Android原生端性能拉胯,求曲线救国的方法。

做了一个测试,生成1000个预制体节点,分别加入2个节点下,每个节点放500个预制体节点。来回隐藏A,B两个节点。在H5上面性能还过得去,但是在android原生上,极为拉胯,估计切一次3秒左右。以下是视频和Demo源码。求破解方法。

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;
        }
    }

}

1赞

我帮你顶下

不严谨 应该用手机浏览器测试 电脑性能比手机强

1赞

把隐藏和出现改成透明度为0/255试试

active在哪个引擎都是消耗点,我们一般是用透明度控制

1赞

如果在节点上有按钮或者事件,控制透明度还是比较烦的,要做事件处理

drawcall太高了,要优化,而且啥需求要这么多带断批label的预制这么变态 :rofl:

测试用例,主要是active消耗问题,透明度控制倒是可以优化这个问题,但是我在想是否能通过切换不同的camera来解决这个问题

感觉这个应该是优先优化drawcall,因为就一个图片和一个label,创建1000个drawcall就1000+了

这么多年了creater的原生问题还是这样的,每次大版本都说性能又增加了多少倍多少倍,实际上嘛,没点斤两优化死你