Exemple #1
0
        public string DeviceNameChosen()
        {
            PlayerPrefsStorage prefsStorage = new PlayerPrefsStorage(Game.ForceVision);

            if (prefsStorage.PrefKeyExists(DeviceNameChosenPlayerPref))
            {
                return(prefsStorage.GetPrefString(DeviceNameChosenPlayerPref));
            }
            return(null);
        }
Exemple #2
0
        protected void Start()
        {
            string             locale       = null;
            PlayerPrefsStorage prefsStorage = new PlayerPrefsStorage(Game.ForceVision);

            if (prefsStorage.PrefKeyExists(Localizer.LanguagePrefKey) == true)
            {
                locale = prefsStorage.GetPrefString(Localizer.LanguagePrefKey);
            }

            toggles = new Toggle[Localizer.Locales.Count];
            //load language prefabs
            bool foundMatch = false;

            for (int i = 0; i < Localizer.Locales.Count; i++)
            {
                GameObject languageGameObject = GameObject.Instantiate(LanguagePrefab);
                toggles[i] = languageGameObject.GetComponent <Toggle>();

                if (languageGameObject != null)
                {
                    if (languageGameObject.GetComponent <LanguageDisplay>() != null)
                    {
                        languageGameObject.transform.SetParent(TargetContent.transform, false);

                        bool isOn = false;
                        if (Localizer.Locales[i].Equals(locale))
                        {
                            isOn       = true;
                            foundMatch = true;
                        }

                        languageGameObject.GetComponent <LanguageDisplay>().Init(i, isOn);
                    }
                }
            }

            LanguageDisplay.OnToggleClick += OnToggleClick;

            ConfirmButton.interactable = foundMatch;
        }
        private void Start()
        {
            Localizer.LoadLanguageDefinitions();

            PlayerPrefsStorage prefsStorage = new PlayerPrefsStorage(Game.ForceVision);

            if (prefsStorage.PrefKeyExists(Localizer.LanguagePrefKey) == true)
            {
                locale = prefsStorage.GetPrefString(Localizer.LanguagePrefKey);
            }

            //verrify pref is valid
            if (Localizer.Locales.IndexOf(locale) < 0)
            {
                locale = Localizer.Locales[0];
            }

            Localizer.Locale = locale;

            int count = 0;
            List <Dropdown.OptionData> options = new List <Dropdown.OptionData>();

            foreach (string languageName in Localizer.LanguageNames)
            {
                if (locale.Equals(Localizer.GetLocaleFromLanguage(languageName)))
                {
                    activeSelection = count;
                }
                count++;
                options.Add(new Dropdown.OptionData()
                {
                    text = languageName
                });
            }
            LanguageDropDownUI.options = options;
            LanguageDropDownUI.value   = activeSelection;
        }