Switch background music

Hello, I have several pieces of BGM and I want to switch from one to another. How should I do that?
I have tried change the eventinstance of emitter but it didn’t work.

Thanks.

Hi,

What version of FMOD are you using?

How are you playing the first BGM event? Could I get a code snippet of how you are trying to change events?

Fmod version is 2.02.11.

I set up event in the inspector and control it in Start method:

private void Start()
{
musicEmitter.Play();
isPlaying = true;
}

Here’s my ChangeMusic method:

public void ChangeMusic(string eventName)
{
musicEmitter.Stop();
musicEmitter.Event = eventName;
musicEmitter.Play();
}

Hi,

Emitter.Event has been deprecated and won’t change the event the emitter will play.

I would recommend making a public list of emitters:

public List<FMODUnity.StudioEventEmitter> emitters = new List<FMODUnity.StudioEventEmitter>();

You can then iterate through to start and stop:

emitters[0].Stop();
emitters[1].Play();

Let me know if this works for you, there are some other options too.

Hope this helps!