IEnumerator destroyCoroutine() { foreach (GameObject particle in particles) { FadeMaterial fader = particle.GetComponent <FadeMaterial>(); if (fader != null) { fader.FadeOut(); } } yield return(new WaitForSeconds(1)); foreach (GameObject particle in particles) { Destroy(particle); } particles = new List <GameObject>(); }
IEnumerator displayCoroutine(int protons, int electrons, int neutrons) { if (particles.Count > 0) { foreach (GameObject particle in particles) { FadeMaterial fader = particle.GetComponent <FadeMaterial>(); if (fader != null) { fader.FadeOut(); } } yield return(new WaitForSeconds(1)); foreach (GameObject particle in particles) { Destroy(particle); } } this.protons = protons; this.electrons = electrons; this.neutrons = neutrons; this.CreateAtom(); }