Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when destroying a child in initialize #1180

Open
vkalpias opened this issue Apr 24, 2018 · 0 comments
Open

Error when destroying a child in initialize #1180

vkalpias opened this issue Apr 24, 2018 · 0 comments
Labels

Comments

@vkalpias
Copy link
Collaborator

To reproduce setup an Entity in the Editor like so:

Parent
 - Child1
 - Child2

Disable the Parent.
Add a script to Child1 that destroys it in initialize like so:

TestScript.prototype.initialize = function () { this.entity.destroy(); }

Create another script to clone the parent like so:

var clone = Parent.clone();
clone.enabled = true;
this.app.root.addChild(clone);

Notice there is an error thrown because in pc.Entity#_notifyHierarchyStateChanged we loop through the children of an entity and since we destroy one of its children that loop is invalid.

@vkalpias vkalpias added the bug label Apr 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant