private void ApplyChangedValueToPreferences(int value, TMP_Dropdown tmpDropdown, Dropdown dropdown, PreferencesSetting setting) { string language = default; if (dropdown) { language = Cultures.GetCultures().First(element => element.NativeName == dropdown.options[value].text).Name; } if (tmpDropdown) { language = Cultures.GetCultures().First(element => element.NativeName == tmpDropdown.options[value].text).Name; } switch (setting) { case PreferencesSetting.TextLanguage: TextLanguage = language; break; case PreferencesSetting.AudioLanguage: AudioLanguage = language; break; } }
private void PopulateLanguagesListToDropdown(List <string> languageList, TMP_Dropdown tmpDropdown, Dropdown dropdown, ref int selectedLanguageIndex, PreferencesSetting setting) { switch (setting) { case PreferencesSetting.TextLanguage: selectedLanguageIndex = languageList.IndexOf(TextLanguage); break; case PreferencesSetting.AudioLanguage: selectedLanguageIndex = languageList.IndexOf(AudioLanguage); break; } var displayNames = new List <string>(); foreach (var culture in languageList) { displayNames.Add(Cultures.GetCulture(culture).NativeName); } if (dropdown) { dropdown.ClearOptions(); dropdown.AddOptions(displayNames); #if UNITY_2019_1_OR_NEWER dropdown.SetValueWithoutNotify(selectedLanguageIndex); #else dropdown.value = selectedLanguageIndex; #endif } if (tmpDropdown) { tmpDropdown.ClearOptions(); tmpDropdown.AddOptions(displayNames); #if UNITY_2019_1_OR_NEWER tmpDropdown.SetValueWithoutNotify(selectedLanguageIndex); #else tmpDropdown.value = selectedLanguageIndex; #endif } }