title: How to fade out audio/music between scenes?
body: <p>I'm trying to get some music to fade out when I start my android game. The music plays in the main menu and then should fade out when the player clicks play. I can get the music to stop, just not fade out.</p>
  
  <p>Im trying to fade out using this:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class MusicScript : MonoBehaviour 
  {
      static MusicScript instance;
      bool doneFading;
  
      void Start()
      {
          if(instance == null)
          {
              instance = this;
              DontDestroyOnLoad(gameObject);
          }
  
          else if (instance != this)
          {
              Destroy(gameObject);
          }
      }
  
      void Update()
      {
          if (Application.loadedLevelName == "Flappy Drone Gameplay Screen")
          {
              FadeMusic();
              if (doneFading == true)
              {
                  Destroy(gameObject);
              }
          }
      }
  
      IEnumerator FadeMusic()
      {
          for (int i = 9; i &gt; 0; i--)
          {
              Debug.Log("here");
              instance.audio.volume = i * 0.1f;
              yield return new WaitForSeconds(0.5f);
              Debug.Log("lowered volume");
          }
          doneFading = true;
      }
  
  }
  </code></pre>
  
  <p>Any help is appreciated!</p>