Hi guys, my goal here is to pause the game’s music when the player activates the pause screen and continue the music when the player resumes gameplay. Here is my code for the pause menu, excluding non-FMOD affiliated code:

using UnityEngine;
using System.Collections;

public class PauseMenu : MonoBehavior {

    public FMODAsset setPause_On;
    public FMODAsset setPause_Off;
    public FMOD.ChannelGroup MUSIC;

    void OnGUI() {
        if (!IsPaused) {
            if (pause button is pressed) {
                MUSIC.setPaused (true);
                FMOD_StudioSystem.instance.PlayOneShot (setPause_On, transform.position);

        if (IsPaused) {
            if (resume button is pressed) {
                FMOD_StudioSystem.PlayOneShot(setPause_Off, transform.position);
                MUSIC.setPaused (false);

As expected, my OneShots are playing correctly with the appropriate button presses but I’m getting a null reference error because my MUSIC variable is empty. How do I point this variable in Unity to the FMOD ChannelGroup of the same name? I imagine there would be one of two possible solutions:

1) Assigning the variable to the ChannelGroup when the variable is declared

public FMOD.ChannelGroup MUSIC = (whatever the path for the MUSIC ChannelGroup is);


Or (2) using the ChannelGroup::getGroup function, whose documentation only exists in C++ and C here: Official ChannelGroup::getGroup Documentation

The C# Wrapper for FMOD says this of the ChannelGroup::getGroup function:

 public class ChannelGroup : ChannelControl
        public RESULT getGroup               (int index, out ChannelGroup group)
            group = null;
            IntPtr groupraw;
            RESULT result = FMOD5_ChannelGroup_GetGroup(getRaw(), index, out groupraw);
            group = new ChannelGroup(groupraw);

            return result;

The problem with this 2nd solution is that I am not a programmer and have only taught myself the bare minimum to make my audio deadlines for this project, so I have no idea how to translate the official documentation to C#, nor can I immediately determine how to point my variable at the actual ChannelGroup itself from looking at the C# wrapper.

I hate writing up such a large support ticket for such a seemingly simple operation, but either the above documentation does not answer my question or I am simply too much of a novice to decipher any solutions from the above documentation. Any help would be greatly appreciated! :]

Thank you for your time.


  • You must to post comments
Best Answer

Hi, you are correct that the documentation currently only mentions C++ and C, not C#. The C# interface is a direct 1-1 mapping so the documentation is still relevant.

If you are using FMOD Studio with Unity, you normally wouldn’t need to work on
ChannelGroups at all. The simplest way is to music event instance directly. This sort of code would work:

FMOD.Studio.EventInstance music = FMOD_StudioSystem.GetEvent(asset);
// then, to pause and unpause

If you instead want to pause the music by pausing an entire bus, then you will want to do the following:

FMOD.Studio.Bus musicBus;
FMOD_StudioSystem.System.getBus("bus:/music_bus_name", out musicBus);
// then, to pause and unpause

If you did want to get the underlying channelgroup of an event instance or a bus, you can do that too by getChannelGroup on the bus or event instance. There are some caveats with these functions which you can read about here:

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.