From c39e53f1d24cf36775c5be429096649d1e0c771d Mon Sep 17 00:00:00 2001 From: finscn Date: Fri, 6 Feb 2026 00:36:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=A7=E8=A1=8C=20`node->?= =?UTF-8?q?=5FsetColorDirty(false)`=E7=9A=84=E6=97=B6=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 只有在 colorDirty 真正发挥过作用后 ,再执行 node->_setColorDirty(false). 目前的逻辑存在一个 bug: 某帧: - node.colorDirty=true, - 但是 entity.isEnabled === false, - 那么 entity 的 透明度并不会被更新. - 可是在这一帧 node.colorDirty 仍然被设置为了 false. 下一帧: - entity.isEnabled === true 了, - 但是 node.colorDirty 在上一帧已经被设置为 false - 当前帧 entity 的 透明度仍然不会被更新 其实 cocos在 ts 端的逻辑也是 只有 visible 时, 才去修改 opacityDirty . ----- 我在实际项目中遇到的现象是 对 某个当前不可用 的 label 节点设置 透明度 , 当节点可用时 之前设置的透明度无效. --- native/cocos/2d/renderer/Batcher2d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/cocos/2d/renderer/Batcher2d.cpp b/native/cocos/2d/renderer/Batcher2d.cpp index eb3947e1c4..d7d7ffbfab 100644 --- a/native/cocos/2d/renderer/Batcher2d.cpp +++ b/native/cocos/2d/renderer/Batcher2d.cpp @@ -272,7 +272,7 @@ void Batcher2d::walk(Node* node, float parentOpacity, bool parentColorDirty) { / } } - if (isCurrentColorDirty) { + if (isCurrentColorDirty && (!entity || visible && entity->isEnabled())) { node->_setColorDirty(false); }