场景内大量相同图片,修改层级后无法合批

不同的图片会在相同的StaticVBAccessor请求chunk,大量创建图片后超过了StaticVBAccessor的临界值,导致后面的sprite的renderData使用的chunk的bufferid不同,修改层级后不同buffid的图片穿插,导致相同图片无法合批, 请问有没有好的解决办法 。
可不可以为Sprite指定单独的 chunk, 或者合批忽略buffid

测试代码如下

import { _decorator, Component, instantiate, math, Node } from 'cc';

const { ccclass, property } = _decorator;

@ccclass('NewComponent')

export class NewComponent extends Component {

    @property(Node) node1: Node

    @property(Node) node2: Node

    @property(Node) parnet1: Node

    @property(Node) parnet2: Node

    @property count = 1000

    start() {

        for (let i = 0; i < this.count; i++) {

            const el1 = instantiate(this.node1)

            el1.parent = this.parnet1

           

            const el2 = instantiate(this.node2)

            el2.parent = this.parnet2

        }

        for (let i = 0; i < this.count; i++) {

            const child = this.parnet1.children[i]

            child.setSiblingIndex(math.randomRangeInt(i, this.count ))

        }

    }

}

@jare

屏幕截图 2024-01-16 123217

@zzf_Cocos

renderData不对那就设置层级后重新生成一下renderData?

        for (let i = 0; i < this.count; i++) {
            const child = this.parnet1.children[i]
            child.setSiblingIndex(math.randomRangeInt(i, this.count ))
        }
        for (let i = 0; i < this.count; i++) {
            const child = this.parnet1.children[i]
            let sprite = child.getComponent(Sprite)
            sprite.destroyRenderData()
            sprite._flushAssembler()
            //或者设置fillType来触发
           //let originType = sprite.fillType
           //sprite.fillType = 2 - originType
          // sprite.fillType = originType
        }
1赞

把现在的144 数量增大 就好。 比如到288 ,576 等。