title: How can I control the changes of the audio made in main menu to be applied also to the in game scene audio settings?
body: <p>I have two scenes Game and Main Menu.
  I have two sliders in the Main Menu I can control the music volume and the sfx volume and save the changes and it's working fine.</p>
  <p>The main menu have his own audio mixer for that and the game scene have his own audio mixer.
  How can I apply the changes I'm doing in the main menu volume/s to be apply also in the volumes of the game scene audio mixer ?</p>
  <p>This is a screenshot of the audio mixer in the Game scene, I added empty game object name it Game Audio :</p>
  <p><a href="https://i.stack.imgur.com/m9QXQ.jpg" rel="nofollow noreferrer">Game Audio settings</a></p>
  <p>The same settings copy of the settings for the main menu scene audio mixer :</p>
  <p>Screenshot of the main menu audio settings :</p>
  <p><a href="https://i.stack.imgur.com/L35Jj.jpg" rel="nofollow noreferrer">main menu audio settings</a></p>
  <p>Later I will change the music clip and sfx effects in the game scene.
  The reason for two mixers each for main menu and game scenes is to be able to control the music and sfx individual in each scene.</p>
  <p>This script Settings is in the Main Menu scene and control the music and sfx sliders volumes :</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.Audio;
  using UnityEngine.UI;
  using TMPro;
  using System;
  using UnityEngine.Events;
  using System.Linq;
  
  public class Settings : MonoBehaviour
  {
      public AudioMixer audioMixer;
      public TMP_Dropdown resolutionDropdown;
      public TMP_Dropdown qualityDropdown;
      public Text musicText;
      public Text sfxText;
      public Slider[] audioSliders;
      public Toggle fullScreenToggle;
  
      private Resolution[] resolutions;
  
      private void Awake()
      {
          resolutionDropdown.onValueChanged.AddListener(new UnityAction&lt;int&gt;(index =&gt;
          {
              PlayerPrefs.SetInt(&quot;resolutionvalue&quot;, resolutionDropdown.value);
              PlayerPrefs.Save();
  
          }));
  
          qualityDropdown.onValueChanged.AddListener(new UnityAction&lt;int&gt;(index =&gt;
          {
              PlayerPrefs.SetInt(&quot;qualityvalue&quot;, qualityDropdown.value);
              PlayerPrefs.Save();
  
          }));
  
          fullScreenToggle.onValueChanged.AddListener(new UnityAction&lt;bool&gt;(index =&gt;
          {
              PlayerPrefs.SetInt(&quot;fullscreen&quot;, boolToInt(fullScreenToggle.isOn));
              PlayerPrefs.Save();
  
          }));
      }
  
      private void Start()
      {
          qualityDropdown.value = PlayerPrefs.GetInt(&quot;qualityvalue&quot;);
  
          var resolutions = Screen.resolutions.Where(resolution =&gt; resolution.refreshRate == 60).ToArray();
          resolutionDropdown.ClearOptions();
  
          List&lt;string&gt; options = new List&lt;string&gt;();
  
          int currentResolutionIndex = 0;
          for(int i = 0; i &lt; resolutions.Length; i++)
          {
              string option = resolutions[i].width + &quot; x &quot; + resolutions[i].height;
              options.Add(option);
  
              if(resolutions[i].width == Screen.currentResolution.width &amp;&amp;
                  resolutions[i].height == Screen.currentResolution.height)
              {
                  currentResolutionIndex = i;
              }
          }
  
          resolutionDropdown.AddOptions(options);
          resolutionDropdown.value = PlayerPrefs.GetInt(&quot;resolutionvalue&quot;, currentResolutionIndex);
          resolutionDropdown.RefreshShownValue();
  
          float musicvolume = PlayerPrefs.GetFloat(&quot;musicvolume&quot;);
          float sfxvolume = PlayerPrefs.GetFloat(&quot;sfxvolume&quot;);
  
          musicText.text = musicvolume.ToString();
          sfxText.text = sfxvolume.ToString();
          audioSliders[0].value = musicvolume / 100f;
          audioSliders[1].value = sfxvolume / 100f;
  
          fullScreenToggle.isOn = intToBool(PlayerPrefs.GetInt(&quot;fullscreen&quot;, 0));
          
      }
  
      public void SetResolution(int resolutionIndex)
      {
          if (resolutions != null)
          {
              Resolution resolution = resolutions[resolutionIndex];
              Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
          }
      }
  
      public void SetMusicVolume(float volume)
      {
          audioMixer.SetFloat(&quot;musicvol&quot;, Mathf.Log10(volume) * 20);
          musicText.text = Math.Round(volume * 100, MidpointRounding.AwayFromZero).ToString();
  
          PlayerPrefs.SetFloat(&quot;musicvolume&quot;, (float)Math.Round(volume * 100, MidpointRounding.AwayFromZero));
      }
  
      public void SetSfxVolume(float volume)
      {
          audioMixer.SetFloat(&quot;sfxvol&quot;, Mathf.Log10(volume) * 20);
          sfxText.text = Math.Round(volume * 100, MidpointRounding.AwayFromZero).ToString();
  
          PlayerPrefs.SetFloat(&quot;sfxvolume&quot;, (float)Math.Round(volume * 100, MidpointRounding.AwayFromZero));
      }
  
      public void SetQuality(int qualityIndex)
      {
          QualitySettings.SetQualityLevel(qualityIndex);
      }
  
      public void SetFullscreen(bool isFullscreen)
      {
          Screen.fullScreen = isFullscreen;        
      }
  
      int boolToInt(bool val)
      {
          if (val)
              return 1;
          else
              return 0;
      }
  
      bool intToBool(int val)
      {
          if (val != 0)
              return true;
          else
              return false;
      }
  } 
  </code></pre>
  <p>Now when I'm in the main menu scene the game scene is also still loaded and I want that when I change the volume/s in the main menu that it will effect applied to the game audio too. Not same music and sfx in the main menu like in the game but just to know that I changed the volume/s that it will effect the game scene too.</p>
  <p>This script is in the Game scene. In the array objsToDisable I have 3 objects that I disable/enabled and in this array I want to be able to disable/enable the Game audio. I did Expose for both music and sfx in the game audio mixer but not sure how to SetFloat of the Game audio mixer ? Where do I add the float or how do I use it in this script ?</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using TMPro;
  using UnityEngine;
  using UnityEngine.SceneManagement;
  using UnityEngine.UI;
  
  public class BackToMainMenu : MonoBehaviour
  {
      public GameObject[] objsToDisable;
  
      // Start is called before the first frame update
      void Start()
      {
  
      }
  
      // Update is called once per frame
      void Update()
      {
          if (Input.GetKeyDown(KeyCode.Escape))
          {
              if (Time.timeScale == 0)
              {
                  DisableEnableUiTexts(true);
                  SceneManager.UnloadSceneAsync(0);
                  Cursor.visible = false;
                  Time.timeScale = 1;
              }
              else
              {
                  Time.timeScale = 0;
                  MenuController.LoadSceneForSavedGame = false;
                  SceneManager.LoadScene(0, LoadSceneMode.Additive);
                  SceneManager.sceneLoaded += SceneManager_sceneLoaded;
  
                  Cursor.visible = true;
              }
          }
      }
  
      private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
      {
          DisableEnableUiTexts(false);
      }
  
      private void DisableEnableUiTexts(bool enabled)
      {
          foreach (GameObject go in objsToDisable)
          {
              if (go.name == &quot;Cameras&quot;)
              {
                  foreach(Transform child in go.transform)
                  {
                      if(child.name == &quot;Main Camera&quot;)
                      {
                          if (enabled == false)
                          {
                              child.GetComponent&lt;Camera&gt;().enabled = false;
                          }
                          else
                          {
                              child.GetComponent&lt;Camera&gt;().enabled = true;
                          }
                      }
                  }
              }
              else
              {
                  go.SetActive(enabled);
              }
          }
      }
  }
  </code></pre>