Search Unity

Hierarchy filling with "New GameObject" : Memory Leak?

Discussion in 'Scripting' started by lesshardtoofind, Dec 19, 2014.

  1. lesshardtoofind

    lesshardtoofind

    Joined:
    Dec 17, 2014
    Posts:
    3
    Hi,

    I'm not sure if I have a memory leak here but my hierarchy keeps filling with this new game object junk and my destroys don't seem to be removing them.



    The culprit script is as follows:

    Code (CSharp):
    1. public class DestroyByContact : MonoBehaviour {
    2.     public GameObject explosion;
    3.     public GameObject playerexplosion;
    4.     void OnTriggerEnter(Collider other){
    5.         if (other.tag == "Boundary") {
    6.             return;
    7.         }
    8.         if (other.tag == "Player") {
    9.             GameObject pclone = Instantiate (
    10.                playerexplosion,
    11.                other.transform.position,
    12.                other.transform.rotation) as GameObject;
    13.             Destroy (pclone, 1.0f);
    14.         }
    15.         GameObject eclone = Instantiate (
    16.               explosion,
    17.               transform.position,
    18.               transform.rotation) as GameObject;
    19.         Destroy (other.gameObject);
    20.         Destroy (eclone, 1.0f);
    21.         Destroy (gameObject);
    22.     }
    23. }
    Thanks for your time.
    - John
     
  2. lesshardtoofind

    lesshardtoofind

    Joined:
    Dec 17, 2014
    Posts:
    3
    Saved the Project restarted my computer and it went away without editing any code... wonder if this was a bug.