Example #1
0
        /// <summary>
        /// Change current language.
        /// Set default if language not initialized or recognized.
        /// </summary>
        /// <param name="langCode">Language code</param>
        public void setLanguage(LanguageCode langCode)
        {
            if (_langs.ContainsKey(langCode))
            {
                _gameLang = langCode;
            }
            else
            {
                _gameLang = _defaultLang;
                Debug.LogError(string.Format("Language {0} not recognized! Using default language.", langCode));
            }

            PlayerPrefs.SetString(GAME_LANG, _gameLang.ToString());

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

            if (_useCustomFonts)
            {
                I18NFonts newFont = null;
                _currentCustomFont = null;
                if (_langFonts != null && _langFonts.Count > 0)
                {
                    foreach (I18NFonts f in _langFonts)
                    {
                        if (f.lang == _gameLang)
                        {
                            newFont            = f;
                            _currentCustomFont = f;
                            break;
                        }
                    }
                }

                if (OnFontChanged != null)
                {
                    OnFontChanged(newFont);
                }
            }
            else
            {
                _currentCustomFont = null;
            }
        }
Example #2
0
        private void _changeFont(I18NFonts f)
        {
            if (_dontOverwrite)
            {
                return;
            }

            if (f != null)
            {
                if (f.font)
                {
                    //_text.font = f.font;
                    _renderer.material = f.font.material;
                }
                else
                {
                    _text.font         = _defaultFont;
                    _renderer.material = _defaultFont.material;
                }
                if (f.customLineSpacing)
                {
                    _text.lineSpacing = f.lineSpacing;
                }
                if (f.customFontSizeOffset)
                {
                    _text.fontSize = (int)(_defaultFontSize + (_defaultFontSize * f.fontSizeOffsetPercent / 100));
                }
                if (f.customAlignment)
                {
                    //_text.alignment = f.alignment;
                }
            }
            else
            {
                _text.font         = _defaultFont;
                _renderer.material = _defaultFont.material;
                _text.lineSpacing  = _defaultLineSpacing;
                _text.fontSize     = _defaultFontSize;
                //_text.alignment = _defaultAlignment;
            }
        }
Example #3
0
        private void _changeFont(I18NFonts f)
        {
            if (_dontOverwrite)
            {
                return;
            }

            if (f != null)
            {
                if (f.font)
                {
                    _dropdown.itemText.font = f.font;
                }
                else
                {
                    _dropdown.itemText.font = _defaultFont;
                }
                if (f.customLineSpacing)
                {
                    _dropdown.itemText.lineSpacing = f.lineSpacing;
                }
                if (f.customFontSizeOffset)
                {
                    _dropdown.itemText.fontSize = (int)(_defaultFontSize + (_defaultFontSize * f.fontSizeOffsetPercent / 100));
                }
                if (f.customAlignment)
                {
                    _dropdown.itemText.alignment = _getAnchorFromAlignment(f.alignment);
                }
            }
            else
            {
                _dropdown.itemText.font        = _defaultFont;
                _dropdown.itemText.lineSpacing = _defaultLineSpacing;
                _dropdown.itemText.fontSize    = _defaultFontSize;
                _dropdown.itemText.alignment   = _defaultAlignment;
            }
        }
Example #4
0
 private void _onFontChanged(I18NFonts newFont)
 {
     _changeFont(newFont);
 }