Unity Editor's mute button doesn't work?

  1. We are using addressables (Asset Bundles are selected in import settings)
  2. Currently we have both built-in Unity and FMOD sound engines active (we are slowly migrating)
  3. We load banks manually, using AssetReferences.

So far I came across this property:
image
If we set breakpoint and inspect Settings.Instance.MasterBanks:


and then check the HasBankLoaded method…

… we can see that keys are stored as guids, but settings instance has a literal bank name.
HaveMasterBanksLoaded is used in ApplyMuteState() and my wild guess is that it just works wrong?

Hi,

What version of FMOD and Unity are you using?

Unity 2020.3.41f1
Reproduced both at FMOD 2.02.11 and 2.02.13

1 Like

Hi,

Thank you for the information. Is the issue when you are trying to apply mute to the master bank or when you are selecting the mute button in the game view?

Hi,

I was talking about the mute button in the game view.

Hi,

Thank you for the clarification. When I tested a scene using Asset Bundles I was able to mute the audio using the button in the game view. Apologies if I have miss understood but what is the exact issue you are experiencing?

I’ve been unable to mute using the button in game view, that IS my problem. I’m assuming that for some reason the FMOD Unity API thinks the master banks are not loaded, but in fact they are! Did you see my screenshots above?

  1. The HasBankLoaded(string loadedBank) method in RuntimeManager could never return true because loadedBanks keys are stored as guids, and we are trying to find a Master bank by name. (This can be seen in the screenshots in the original post).
  2. This method is used in HaveAllMasterBanksLoaded property.
  3. The HaveAllMasterBanksLoaded property is used in ApplyMuteState method:
private static void ApplyMuteState()
        {
            if (HaveMasterBanksLoaded)
            {
                FMOD.Studio.Bus masterBus;
                if (StudioSystem.getBus("bus:/", out masterBus) == FMOD.RESULT.OK)
                {
                    #if UNITY_EDITOR
                    masterBus.setMute(Instance.isMuted || EditorUtility.audioMasterMute);
                    #else
                    masterBus.setMute(Instance.isMuted);
                    #endif
                }
            }
        }

I think because HaveMasterBanksLoaded returns false, the sound is not muted. (All of this is in the Unity FMOD API, it’s not our code).

Here is our code for loading banks:

public async UniTask LoadBanksAsync(IEnumerable<AssetReference> bankReferences, bool preloadSamples,
			CancellationToken token)
		{
			foreach (AssetReference bankRef in bankReferences)
			{
				try
				{
					RuntimeManager.LoadBank(bankRef, preloadSamples);
				}
				catch (BankLoadException e)
				{
					GGLogger.Exception($"Exception while trying to load bank: {bankRef}", e);
				}
			}

			await UniTask.WaitUntil(() => RuntimeManager.HaveAllBanksLoaded, cancellationToken: token);
			await UniTask.WaitUntil(() => RuntimeManager.AnySampleDataLoading() == false, cancellationToken: token);
		}

We use UniTask for asynchronous tasks

Hi,

Thank you for providing the code. I have now found the issue. I will pass this on to our development team to look into further.

In the meantime, if you add the following to the HasBankLoadedFunction() it will allow you to use the mute button:

public static bool HasBankLoaded(string loadedBank)
{
    if (Instance.loadedBanks.Count != 0)
    {
        if (!(Instance.loadedBanks.ContainsKey(loadedBank)) && loadedBank == "Master")
		{
            // If we are using Addressables and explicitly looking for the master bank
            FMOD.RESULT result = FMODUnity.RuntimeManager.StudioSystem.getBank("bank:/Master", out FMOD.Studio.Bank masterBank);
            if (result == FMOD.RESULT.OK)
                return true;
            else 
                return false;
        }
        else
            return true;
    }
    return false;
}
1 Like