Search Unity

Sound playing through scenes

Discussion in 'Editor & General Support' started by hgbimonti, Jul 2, 2009.

  1. hgbimonti

    hgbimonti

    Joined:
    Dec 31, 2008
    Posts:
    19
    Hi!

    In my project I have some scenes that are spash screens, loading screens, menu screens and game scene. I'd like to have a music playing in the first scene that plays continuously through the scenes.

    Is this possible?

    Or when I load a new scene, the game object with the AudioSource in the late scene is over and that's it?

    Thanks!
     
  2. Joe-Robins

    Joe-Robins

    Unity Technologies

    Joined:
    Apr 21, 2008
    Posts:
    430
    Hi, this can be achieved by attaching this simple bit of code to the object that contains your AudioSource

    Code (csharp):
    1. function Awake () {
    2. DontDestroyOnLoad (this);
    3. }
    4.  
     
  3. hgbimonti

    hgbimonti

    Joined:
    Dec 31, 2008
    Posts:
    19
    Thanks!

    Hum, and let's supose: I have this object that plays two or more musics. Is it possible to work with it as it does not live in that new scene?