Scrollview optimization. v3.5.0

Hello! Before creator 3.0 we were using this tutorial to optimise all scroll views in our projects:

In version 3.5.0 when i set 0 opacity to a node draw calls do not drop down.

this.node.getComponent(UIOpacity)!.opacity = 0

This way is not good:

this.node.active = false

because it freezes a game

Is there a new good way to optimise a scrollview?

1 Like

Turning off the node is freezing the game? i dont’ understand that.
You could try to disable the scrollview component.

node.getComponent(ScrollView).enabled = false

What do you mean?

I am talking about this:

im’ more confused now. So based on the documentation opacity =0 should work but you are not seeing the draw calls go down. Now you tried node.active=false but that is a huge performance hit? If the node has a sprite component associated, you can disable that so the rendering stops// one more test just like node.active = false.

I set enabled component to false to optimize.
Example:

update (dt) {
      var viewRect = cc.rect(- this.view.width / 2, - this.content.y - this.view.height, this.view.width, this.view.height);
      for (let i = 0; i < this.content.children.length; i++) {
          const node = this.content.children[i];
          if (viewRect.intersects(node.getBoundingBox())) {
              node.getComponent(cc.Sprite).enabled = true;
              node.getChildByName('text').getComponent(cc.Label).enabled = true;
          }
          else {
              node.getComponent(cc.Sprite).enabled = false;
              node.getChildByName('text').getComponent(cc.Label).enabled = false;
          }
      }
}

I have a ticket on github regarding CC3 and opacity = 0 that I really liked in CC2 where it didn’t render and cause drawcalls.

1 Like

Interesting :thinking:

I thought if i change the layer of a node to an other layer, the node will not be rendered. It will not.
But draws calls will not drop down.

A camera of a canvas has UI_2D layer and a node too.
Then i change the layer of the node to an other one(e.g. DEFAULT)

And nothing happed. Draw calls do not drop down.

But this idea works good in v2.4.8.

Yes, if I set active false then true it makes a huge freezing.
I also used opacity 0 for all objects. But it doesn’t drop draw calls.