Beispiel #1
0
    private void Initialize()
    {
        //Read registry keys to setup buttons activity
        if (!MusicManager.instance.isMusic)
        {
            music.GetComponent <Image>().color -= new Color(0, 0, 0, 0.5f);
        }
        if (!MusicManager.instance.isSounds)
        {
            sound.GetComponent <Image>().color -= new Color(0, 0, 0, 0.5f);
        }

        //Attach OnClick methods to menu buttons
        music.onClick.AddListener(() => StaticBehaviors.MusicClick(music));
        sound.onClick.AddListener(() => StaticBehaviors.SoundsClick(sound));
        backToGame.onClick.AddListener(() => gameObject.SetActive(false));
        backToMainMenu.onClick.AddListener(() => StaticBehaviors.LoadScene(0));
        exit.onClick.AddListener(() => Application.Quit());
    }
    private IEnumerator Initialize()
    {
        yield return(new WaitUntil(() => MusicManager.instance != null)); //Make sure that MusicManager is loaded

        directorys.gameObject.SetActive(false);

        //Set up sounds buttons color
        if (!MusicManager.instance.isMusic)
        {
            music.GetComponent <Image>().color -= new Color(0, 0, 0, 0.5f);
        }
        if (!MusicManager.instance.isSounds)
        {
            sounds.GetComponent <Image>().color -= new Color(0, 0, 0, 0.5f);
        }
        //Add OnClick methods to all buttons
        play.onClick.AddListener(PlayHandler);
        info.onClick.AddListener(() => { gameinfo.gameObject.SetActive(true); MusicManager.instance.PlaySound("blup"); });
        exit.onClick.AddListener(() => Application.Quit());
        back.onClick.AddListener(BackHandler);
        music.onClick.AddListener(() => StaticBehaviors.MusicClick(music));
        sounds.onClick.AddListener(() => StaticBehaviors.SoundsClick(sounds));

        if (DataManager.Instance.adsSettings.GDPRconsent) //Add GDPR button to the settings panel
        {
            gdpr.gameObject.SetActive(true);
            gdpr.onClick.AddListener(() => Instantiate(gdprPrefab, mainTransform));
        }

        if (DataManager.Instance.Languages.Count() > 1) //Reveal Language popup if there is more than one language
        {
            language.gameObject.SetActive(true);
            language.onClick.AddListener(() => languagePopup.gameObject.SetActive(true));
            language.onClick.AddListener(() => MusicManager.instance.PlaySound("blup"));
        }
    }