cocos-engine icon indicating copy to clipboard operation
cocos-engine copied to clipboard

Node 的 setScale setPosition 等方法的性能问题

Open finscn opened this issue 1 year ago • 3 comments

Cocos Creator version

3.8.2

System information

all

Issue description

对项目性能进行检测, 发现 setScale 居然成为性能热点之一. 查看源码发现, 3.8.x 里 不会 判断 设置的值和之前的值是否一样, 而是无脑更新 且会调用 invalidateChildren 深度遍历子节点. 以前 2.x 里 是会判断 新设置的值是否和之前不同.

建议 3.8 能加入类似机制.

Relevant error log output

No response

Steps to reproduce

Minimal reproduction project

No response

finscn avatar May 07 '24 05:05 finscn

确实没想到这里会成为热点。你的项目为什么会频繁设置相同的值呢?

minggo avatar May 08 '24 01:05 minggo

确实没想到这里会成为热点。你的项目为什么会频繁设置相同的值呢?

和玩法有关, 游戏里 的物体就是会经常的不断的缩放. 当然我可以自己判断, 只是我以为 3和2 一样 内部会判断呢.

finscn avatar May 09 '24 06:05 finscn

引擎内部是应该做判断的。我会提交修改。

minggo avatar May 09 '24 07:05 minggo