Skip to content

优化执行 node->_setColorDirty(false)的时机#73

Open
finscn wants to merge 1 commit intococos:v4.0.0from
finscn:patch-4
Open

优化执行 node->_setColorDirty(false)的时机#73
finscn wants to merge 1 commit intococos:v4.0.0from
finscn:patch-4

Conversation

@finscn
Copy link

@finscn finscn commented Feb 5, 2026

只有在 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 节点设置 透明度 , 当节点可用时 之前设置的透明度无效.

Re: #

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

只有在  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 节点设置 透明度 , 当节点可用时 之前设置的透明度无效.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant