void RemoveParticles()
 {
     foreach (var ps in Light.GetComponentsInChildren <ParticleSystem>())
     {
         Destroy(ps.gameObject);
     }
 }
Exemple #2
0
    IEnumerator LightOff()
    {
        float lastFrame = Time.time;

        while (true)
        {
            if (timerBeam / timeToFinishLightBeam >= 1.0f)
            {
                foreach (var item in lightBeam.GetComponentsInChildren <ParticleSystem>())
                {
                    item.gameObject.SetActive(false);
                }

                StartCoroutine(nameof(LightOn));
                break;
            }


            lightBeam.intensity = Mathf.Lerp(beamInstensity, 1f, timerBeam / timeToFinishLightBeam);
            startText.color     = new Color(.85f, .85f, .85f, Mathf.Lerp(1f, 0f, timerBeam / timeToFinishLightBeam));

            timerBeam += Time.time - lastFrame;
            lastFrame  = Time.time;

            yield return(new WaitForSeconds(.0167f));
        }
        yield return(null);
    }