How do I save the background music in the settings?
The problem is when I set the bgm to low volume or high volume the music return to its settings after the next scene. Here is my code.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class VolumeSettings : MonoBehaviour {
 //reference to audio source
 private AudioSource audioSrc;
 private float musicVolume = 1f;
 // Use this for initialization
 void Start () {
     audioSrc = GetComponent<AudioSource> ();
     
 }
 
 // Update is called once per frame
 void Update () {
     audioSrc.volume = musicVolume;
 }
 void SaveMusic (){
     PlayerPrefs.SetFloat ("Game Volume", musicVolume);
     PlayerPrefs.GetFloat ("Game Volume");
 }
 public void SetVolume(float vol)
 {
     musicVolume = vol;
 }
 
               }
               Comment
              
 
               
              Your answer