예제 #1
0
        public Font getFontPerLanguage(LanguageEntry lang)
        {
            if (lang.hasCustomFont())
            {
                return(lang.getCustomFont());
            }

            return(defaultFont);
        }
예제 #2
0
        public TMP_FontAsset getTextMeshFontPerLanguage(LanguageEntry lang)
        {
            if (lang.hasCustomTextMeshFont())
            {
                return(lang.getCustomTextMeshFont());
            }

            return(defaultTextMeshFont);
        }
예제 #3
0
        public void initialise()
        {
            if (!initialised)
            {
                if (languagesSetup != null)
                {
                    if (languagesSetup.getSupportedLanguagesAmount() > 0)
                    {
                        defaultLanguage = languagesSetup.getDefaultLanguage();
                        if (defaultLanguage == null)
                        {
                            defaultLanguage = languagesSetup.getLanguage(0);

                            printDebugLog("The default language defined in the setup cannot be found. Fallback to the first language provided.", LogType.Error);
                        }

                        currentLanguage = defaultLanguage;

                        retrieveSavedUserLanguageHandler = PlayerPrefsStoredLanguageHandlers.getLanguageFromPlayerPrefs;
                        storeSavedUserLanguageHandler    = PlayerPrefsStoredLanguageHandlers.saveLanguageOnPlayerPrefs;

                        languagesSetup.warmUp();

                        if (storeLanguageOnUserPrefs)
                        {
                            loadSavedUserLang();
                        }

                        initialised = true;
                    }
                    else
                    {
                        printDebugLog("No Languages defined in the Localisation Setup provided, make sure at least one language is supported. Skipping initialisation.", LogType.Error);
                    }
                }
                else
                {
                    printDebugLog("No Languages Setup provided, make sure to create and assign it. Skipping initialisation.", LogType.Error);
                }
            }
        }
예제 #4
0
        public void setLanguage(LanguageEntry entry)
        {
            printDebugLog("Settings language to " + entry.getLanguage(), LogType.Log);

            currentLanguage = entry;

            if (storeLanguageOnUserPrefs)
            {
                if (storeSavedUserLanguageHandler != null)
                {
                    var isoCode = LanguageUtils.getISOCodeFromLanguage(entry.getLanguage());
                    printDebugLog("Storing saved language in User Prefs: " + isoCode, LogType.Log);
                    storeSavedUserLanguageHandler.Invoke(isoCode);
                }
            }

            if (OnLanguageChanged != null)
            {
                OnLanguageChanged();
            }
        }