playcanvas / playcanvas/engine
Disabling in `initialize` while a template is being instantiated does not correctly disable nested elements
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 222
Description
Description
When spawning a template, if any script inside the template disables the entity it is attached to immediately in initialize, then any nested elements to that entity are not disabled correctly. This leads to a broken enabled state, where children of the disabled entity are still enabled in the hierarchy.
Here is a link to a very simple project that reproduces this bug:
https://playcanvas.com/editor/project/1088612
I've reproduced the bug in both the Brave and Firefox browsers.
Steps to Reproduce
- Open the project in the editor. Observe that the TemplateSpawner will spawn a template when initialized. This template includes multiple children that have scripts attached that will disable themselves in
initialize. - Run the project.
- The green box dissapears correctly. The red box does not dissapear like it is supposed to.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction project and trace template instantiation, the TemplateSpawner, and scripts that disable their entities in initialize. Confirm the enabled-state behavior for nested elements, then verify that children of an entity disabled during initialization are also disabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100