public void MusicButton() { if (PlayerPrefs.HasKey("Music")) { if (PlayerPrefs.GetInt("Music") == 0) { musicButton.sprite = musicOnSprite; SoundScript.Play(gameMusic); PlayerPrefs.SetInt("Music", 1); } else { musicButton.sprite = musicOffSprite; //SoundScript.Pause(gameMusic, 0); PlayerPrefs.SetInt("Music", 0); } } else { musicButton.sprite = musicOnSprite; SoundScript.Play(gameMusic); PlayerPrefs.SetInt("Music", 1); } Debug.Log("music" + PlayerPrefs.GetInt("Music")); }
void Start() { backgroundMusic = GetComponent <AudioSource>(); Debug.Log("Game : " + PlayerPrefs.GetInt("musicGame")); SoundScript.Play(gameMusic); //if (PlayerPrefs.HasKey("Music")) //{ // if (PlayerPrefs.GetInt("Music") == 0) // { // musicButton.sprite = musicOffSprite; // SoundScript.Pause(gameMusic, 0); // } // else // { // musicButton.sprite = musicOnSprite; // SoundScript.Play(gameMusic); // } //} //else //{ // musicButton.sprite = musicOnSprite; // SoundScript.Play(gameMusic); //} }
// Start is called before the first frame update void Start() { Debug.Log("start" + PlayerPrefs.GetInt("musicGame")); PlayerPrefs.SetInt("musicGame", 1); backgroundMusic = GetComponent <AudioSource>(); SoundScript.Play(startMusic); settingPanel.SetActive(false); }
public void GameSound() { int sound = PlayerPrefs.GetInt("musicGame"); Debug.Log("musicGame" + PlayerPrefs.GetInt("musicGame")); if (sound == 1) { SoundScript.Play(startMusic); PlayerPrefs.SetInt("musicGame", 0); } else if (sound == 0) { SoundScript.Play(startMusic); PlayerPrefs.SetInt("musicGame", 1); } }
// Start is called before the first frame update void Start() { backgroundMusic = GetComponent <AudioSource>(); SoundScript.Play(splashMusic); Debug.Log("Menu" + PlayerPrefs.GetInt("musicGame")); Loade(); StartCoroutine(RestoreRoutine()); gameData = FindObjectOfType <GameData>(); backSplash = FindObjectOfType <BackToSplash>(); int tutal = PlayerPrefs.GetInt("totalEnergy"); int firstEnergy = PlayerPrefs.GetInt("FirstE"); if (tutal == 1 && firstEnergy != 1) { PlayerPrefs.SetInt("totalEnergy", 5); Loade(); StartCoroutine(RestoreRoutine()); } else { Loade(); StartCoroutine(RestoreRoutine()); } coin = PlayerPrefs.GetInt("Coin"); int firstCoin = PlayerPrefs.GetInt("First"); if (coin == 0 && firstCoin != 1) { coinText.text = "" + 1000; PlayerPrefs.SetInt("Coin", 1000); } else { coinText.text = coin.ToString(); } }