Skip to content

Instantly share code, notes, and snippets.

@EliCDavis
Last active July 7, 2018 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EliCDavis/5ce23ddb569fbf607def1cf84ac38c62 to your computer and use it in GitHub Desktop.
Save EliCDavis/5ce23ddb569fbf607def1cf84ac38c62 to your computer and use it in GitHub Desktop.
private void Close()
{
ParticleSystem particleSystem = GetComponent<ParticleSystem>();
particleSystem.Stop();
Destroy(gameObject, particleSystem.main.startLifetime.constantMax);
StartCoroutine(FadeTime(particleSystem.main.startLifetime.constantMax));
}
private System.Collections.IEnumerator FadeTime(float timeToFadeIt)
{
float timeRemaining = timeToFadeIt;
while (timeRemaining > 0)
{
audio.volume = timeRemaining / timeToFadeIt;
timeRemaining -= Time.deltaTime;
yield return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment