Exemple #1
0
    public static void SetupAudio()
    {
        if (bSoundOn)
        {
            NGUITools.soundVolume = 1;
            PlayerPrefs.SetInt(PREF_SETTING_AUDIO, 1);
        }
        else
        {
            NGUITools.soundVolume = 0;
            PlayerPrefs.SetInt(PREF_SETTING_AUDIO, 0);
        }
        Gamestate gs = GameObject.FindGameObjectWithTag("Gamestate").gameObject.GetComponent <Gamestate>();

        if (gs)
        {
            gs.GetComponent <AudioSource>().enabled = bSoundOn;
            if (gs.GetComponent <AudioSource>().enabled&& gs.GetComponent <AudioSource>().isPlaying == false)
            {
                gs.GetComponent <AudioSource>().Play();
            }
        }
        else
        {
            Debug.LogError("SetupAudio fail");
        }
    }