[SOLVED] enabledSelf / enabledInHierarchy

Hi folks, :slight_smile:

Does PlayCanvas have something akin to Unity’s distinction between activeSelf and activeInHierarchy?

I can only find enabled, but using that messes up its children and changes their values.

What I’d like to do is to have a parent Entity be disabled and its child Entity be enabled (actually disabled in hierarchy because of disabled parent). That way, when I enable the parent, I’d expect the child to be enabled as well.

Is this not supported in the PlayCanvas engine? It seems to work that way in the editor, but I can’t get it working in a raw engine project.

Thanks

Hi @damvad!

If the child is enabled but disabled because the parent is disabled then the child is also enabled when you enable the parent. So if I understand you correctly it should work as you describe.

It does work in a way you described. Internally, the engine maintains enabled in hierarchy flag. See the relevant code here: https://github.com/playcanvas/engine/blob/3b25ac1febd994f3e137963d02c294b65ded5d0c/src/scene/graph-node.js#L259-L273

There are two small issues relating to handling of the enabled in hierarchy flag, that I’ve fixed in the last few days that should be released next week hopefully, but those were pretty hard to repro, not a common case.

If you find some issue, perhaps try to set up a minimal project that demonstrates it, and post it for us to look at.

1 Like

Ooh thanks for answering, guys :smiley: Yes, it does indeed.

For my purpose, I’ll just have to read from _enabled instead of enabled, and set via the setter.