private void UpdateSiblingIndex() { if (_fontController == null || _languageController.SelectedLanguage == null || _fontController.GetByCulture(_languageController.SelectedLanguage.Culture) == null) { return; } transform.SetSiblingIndex(_fontController.GetByCulture(_languageController.SelectedLanguage.Culture).IsRightToLeft ? RightSiblingIndex : LeftSiblingIndex); }
protected virtual void ApplyFontSettings(string culture = null) { if (_fontController == null) { return; } string selectedCulture = FontController.Default; if (_languageController != null && _languageController.SelectedLanguage != null) { selectedCulture = _languageController.SelectedLanguage.Culture; } var fontInfo = _fontController.GetByCulture(culture != null ? culture : selectedCulture); if (fontInfo == null) { return; } // Apply font size. switch (FontSize) { case FontSizes.Header1: _text.fontSize = fontInfo.H1Size; break; case FontSizes.Header2: _text.fontSize = fontInfo.H2Size; break; case FontSizes.Header3: _text.fontSize = fontInfo.H3Size; break; case FontSizes.Body: _text.fontSize = fontInfo.BodySize; break; case FontSizes.Small: _text.fontSize = fontInfo.SmallSize; break; case FontSizes.Button: _text.fontSize = fontInfo.ButtonSize; break; } // Apply font. if (!OverrideFont) { _text.font = fontInfo.Font; } // Apply right to left. _text.isRightToLeftText = fontInfo.IsRightToLeft; if (!OverrideOutlining) { if (_text.alignment == TextAlignmentOptions.Left || _text.alignment == TextAlignmentOptions.Right) { _text.alignment = _text.isRightToLeftText ? TextAlignmentOptions.Right : TextAlignmentOptions.Left; } else if (_text.alignment == TextAlignmentOptions.TopLeft || _text.alignment == TextAlignmentOptions.TopRight) { _text.alignment = _text.isRightToLeftText ? TextAlignmentOptions.TopRight : TextAlignmentOptions.TopLeft; } else if (_text.alignment == TextAlignmentOptions.BottomLeft || _text.alignment == TextAlignmentOptions.BottomRight) { _text.alignment = _text.isRightToLeftText ? TextAlignmentOptions.BottomRight : TextAlignmentOptions.BottomLeft; } } }