If I start a music track in one level and the next level starts, can I have the track not stop and continue playing through to the next level?
Is this possible in Unity?
If I start a music track in one level and the next level starts, can I have the track not stop and continue playing through to the next level?
Is this possible in Unity?
Something like this works in my game, attach it to a GameObject that won't be destroyed:
public var SoundClip : AudioClip;
private var SoundSource : AudioSource;
function Awake()
{
DontDestroyOnLoad(gameObject);
SoundSource = gameObject.AddComponent(AudioSource);
//SoundSource.playOnAwake = false;
//SoundSource.rolloffMode = AudioRolloffMode.Logarithmic;
//SoundSource.loop = true;
}
function Start()
{
SoundSource.clip = SoundClip;
SoundSource.Play();
}
I'd try this: http://unity3d.com/support/documentation/ScriptReference/Object.DontDestroyOnLoad.html
Though playing music while the scene changes (i.e when loading after Application.LoadLevel call) doesn't work unless you have pro and can load the level async.
You could take a look at SoundManagerPro, it handles that kind of stuff