# Unity Editor's mute button doesn't work?

**URL:** <https://qa.fmod.com/t/unity-editors-mute-button-doesnt-work/20088>\
**Category:** Unity\
**Created:** [April 10, 2023, 4:30pm UTC](https://qa.fmod.com/t/unity-editors-mute-button-doesnt-work/20088 "2023-04-10T16:30:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaitekinafune](https://avatars.discourse-cdn.com/v4/letter/k/a183cd/32.png) [@kaitekinafune](https://qa.fmod.com/u/kaitekinafune)\
**Post date:** [April 10, 2023, 4:30pm UTC](https://qa.fmod.com/t/unity-editors-mute-button-doesnt-work/20088/1 "2023-04-10T16:30:38Z")

</div>

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](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/489532300556bd0032fc78f27dc1a0f5d3de25e2.png)  
If we set breakpoint and inspect `Settings.Instance.MasterBanks`:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/4fcaf819ad0c6a88dc7417cbb048490a8bddca8e.png)  
and then check the `HasBankLoaded` method…  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/8/811180f628f45ae0105db9dbdec5d5df19c7d407.png)  
… 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?

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [April 11, 2023, 6:01am UTC](https://qa.fmod.com/t/unity-editors-mute-button-doesnt-work/20088/2 "2023-04-11T06:01:06Z")

</div>

Hi,

What version of FMOD and Unity are you using?

---

<div class="post-metadata">

**Author:** ![kaitekinafune](https://avatars.discourse-cdn.com/v4/letter/k/a183cd/32.png) [@kaitekinafune](https://qa.fmod.com/u/kaitekinafune)\
**Post date:** [April 11, 2023, 6:22am UTC](https://qa.fmod.com/t/unity-editors-mute-button-doesnt-work/20088/3 "2023-04-11T06:22:09Z")

</div>

Unity 2020.3.41f1  
Reproduced both at FMOD 2.02.11 and 2.02.13

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [April 13, 2023, 12:15am UTC](https://qa.fmod.com/t/unity-editors-mute-button-doesnt-work/20088/4 "2023-04-13T00:15:25Z")

</div>

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?

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/1/1ba0d0a3be48762eacc12fbed4c5f881fd05e7ec.png)

---

<div class="post-metadata">

**Author:** ![kaitekinafune](https://avatars.discourse-cdn.com/v4/letter/k/a183cd/32.png) [@kaitekinafune](https://qa.fmod.com/u/kaitekinafune)\
**Post date:** [April 13, 2023, 5:55am UTC](https://qa.fmod.com/t/unity-editors-mute-button-doesnt-work/20088/5 "2023-04-13T05:55:11Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [April 13, 2023, 11:20pm UTC](https://qa.fmod.com/t/unity-editors-mute-button-doesnt-work/20088/6 "2023-04-13T23:20:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kaitekinafune](https://avatars.discourse-cdn.com/v4/letter/k/a183cd/32.png) [@kaitekinafune](https://qa.fmod.com/u/kaitekinafune)\
**Post date:** [April 14, 2023, 4:56pm UTC](https://qa.fmod.com/t/unity-editors-mute-button-doesnt-work/20088/7 "2023-04-14T16:56:41Z")

</div>

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:

```auto
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:

```auto
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

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [April 17, 2023, 6:10am UTC](https://qa.fmod.com/t/unity-editors-mute-button-doesnt-work/20088/8 "2023-04-17T06:10:19Z")

</div>

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:

```auto
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;
}

```
