Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Disabled children aren't destroyed

Discussion in 'Project Tiny' started by mansiva2000, Jan 29, 2019.

  1. mansiva2000

    mansiva2000

    Joined:
    Jul 2, 2013
    Posts:
    9
    I've been running into issues with memory consumption in my game where explosions instantiate particle systems that later get destroyed, similar to what the MatchThree sample project does when matching gems.

    I've noticed that particle systems automatically create a Disabled copy of the particle referenced in the ParticleEmitter component, which I guess is necessary to ensure a consistency during the emission process. However once the ParticleSystem entity is destroyed via ut.Core2D.TransformService.destroyTree(this.world, entity, true), the Disabled particle lingers. Inspection of its ut.Core2D.TransformNode shows that it still references its parent entity even if said entity does not exist anymore.

    This issue actually occurs when destroying any entity that has disabled children. Simply create an entity with a disabled child, destroy the parent entity and notice that the disabled child still exists.

    Obviously destruction should be used sparingly as the documentation states, so I've started reusing those entites with a pool system. Nonetheless destruction of an entity should completely annihilate it and any poor children hiding inside it.

    Peace