/// <summary> /// removes the Entity from the scene and destroys all children /// </summary> public void destroy() { _isDestroyed = true; scene.entities.remove(this); transform.parent = null; // destroy any children we have for (var i = transform.childCount - 1; i >= 0; i--) { var child = transform.getChild(i); child.entity.destroy(); } }
/// <summary> /// removes the Entity from the scene and removes all Components and Colliders /// </summary> public void destroy() { scene.entities.remove(this); // destroy any children we have for (var i = 0; i < transform.childCount; i++) { var child = transform.getChild(i); child.entity.destroy(); } transform.parent = null; // remove all our components when we are destroyed components.removeAllComponents(); colliders.removeAllColliders(); }