Node event ACTIVE_IN_HIERARCHY_CHANGED isn't working

Hi all. I am trying to use “ACTIVE_IN_HIERARCHY_CHANGED” event to check in a node is active in hierarchy, but it call my callback only once, then if I check this one it console, it has activeInHierarchy = false, but callback wasn’t call for this:

nodeClone.on(Node.EventType.ACTIVE_IN_HIERARCHY_CHANGED, () => {
	node.active = nodeClone.activeInHierarchy;

	console.log(nodeClone.activeInHierarchy);
	console.log(nodeClone);
});

now logs:

As you see one node has activeInHierarchy = false, but a callback wasn’t called for this:


in console, only previous console logs with activeInHierarchy = true.

Cocos creator 3.4.0

I can ask engineering to have a look.

This problem is due to the fact that when the same state is set repeatedly, the event is not dispatched.


If you switch states it will always trigger.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.