void Start()
        {
            var localizationSettings = LocalizationSettings.GetInstanceDontCreateDefault();

            // Use included settings if one is available.
            if (useActiveLocalizationSettings && localizationSettings != null)
            {
                Debug.Log("Using included localization data");
                return;
            }

            Debug.Log("Creating default localization data");

            // Create our localization settings. If a LocalizationSettings asset has been created and configured in the editor then we can leave this step out.
            localizationSettings = LocalizationSettings.CreateDefault();

            // Replace the default Locales Provider with something we can manage locally for the example
            var simpleLocalesProvider = ScriptableObject.CreateInstance <SimpleLocalesProvider>();

            localizationSettings.SetAvailableLocales(simpleLocalesProvider);

            // Add the locales we support
            simpleLocalesProvider.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.Arabic)));
            simpleLocalesProvider.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.English)));
            simpleLocalesProvider.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.French)));
            simpleLocalesProvider.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.German)));
            simpleLocalesProvider.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.Japanese)));
            simpleLocalesProvider.AddLocale(Locale.CreateLocale(CultureInfo.InvariantCulture));

            // Set English to be our default
            localizationSettings.OnSelectedLocaleChanged += OnSelectedLocaleChanged;
            LocalizationSettings.Instance = localizationSettings;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Restores any previously saved LocalizationSettings
        /// </summary>
        public static void RestoreSettings(bool deleteOld = false)
        {
            if (deleteOld)
            {
                var instance = LocalizationSettings.GetInstanceDontCreateDefault();
                if (instance != null)
                {
                    Object.DestroyImmediate(instance);
                }
            }

            LocalizationSettings.Instance = s_SavedSettings;
            s_SavedSettings = null;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Save the current LocalizationSettings so that they can be restored after a test.
 /// </summary>
 public static void SaveCurrentSettings()
 {
     Assert.IsNull(s_SavedSettings, "Expected there to be no saved settings.");
     s_SavedSettings = LocalizationSettings.GetInstanceDontCreateDefault();
     LocalizationSettings.Instance = null;
 }