using System.Collections; using System.Collections.Generic; using UnityEngine; public class BackSound : MonoBehaviour { // Start is called before the first frame update void Start() { if (GameObject.Find("backsound on") == null) { DontDestroyOnLoad(gameObject); GetComponent().Play(); gameObject.name = "backsound on"; PlayerPrefs.SetFloat("volume", 05); } else { PlayerPrefs.SetFloat("volume", 0); GetComponent().Stop(); } } // Update is called once per frame void Update() { GetComponent().volume = PlayerPrefs.GetFloat("volume"); } }