public void DoLocalize_TMPUGUILabel(string MainTranslation, string SecondaryTranslation)
        {
            {
                //--[ Localize Font Object ]----------
                                #if TextMeshPro_Pre53
                TMPro.TextMeshProFont newFont = GetSecondaryTranslatedObj <TMPro.TextMeshProFont>(ref MainTranslation, ref SecondaryTranslation);
                                #else
                TMPro.TMP_FontAsset newFont = GetSecondaryTranslatedObj <TMPro.TMP_FontAsset>(ref MainTranslation, ref SecondaryTranslation);
                                #endif

                if (newFont != null)
                {
                    if (mTarget_TMPUGUILabel.font != newFont)
                    {
                        mTarget_TMPUGUILabel.font = newFont;
                    }
                }
                else
                {
                    //--[ Localize Font Material ]----------
                    Material newMat = GetSecondaryTranslatedObj <Material>(ref MainTranslation, ref SecondaryTranslation);
                    if (newMat != null && mTarget_TMPUGUILabel.fontMaterial != newMat)
                    {
                        mTarget_TMPUGUILabel.fontMaterial = newMat;
                    }
                }
            }
            if (mInitializeAlignment)
            {
                mInitializeAlignment    = false;
                mOriginalAlignmentTMPro = mTarget_TMPUGUILabel.alignment;
            }
            if (!string.IsNullOrEmpty(MainTranslation) && mTarget_TMPUGUILabel.text != MainTranslation)
            {
                if (Localize.CurrentLocalizeComponent.CorrectAlignmentForRTL)
                {
                    if (mTarget_TMPUGUILabel.alignment <= TMPro.TextAlignmentOptions.TopJustified)
                    {
                        mTarget_TMPUGUILabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.TopRight : mOriginalAlignmentTMPro;
                    }
                    else
                    if (mTarget_TMPUGUILabel.alignment <= TMPro.TextAlignmentOptions.Justified)
                    {
                        mTarget_TMPUGUILabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.Right : mOriginalAlignmentTMPro;
                    }
                    else
                    {
                        mTarget_TMPUGUILabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.BottomRight : mOriginalAlignmentTMPro;
                    }
                }
                mTarget_TMPUGUILabel.text = MainTranslation;
                mTarget_TMPUGUILabel.SetText(MainTranslation, 0);
            }
        }
예제 #2
0
        public void DoLocalize_TMPUGUILabel(string MainTranslation, string SecondaryTranslation)
        {
            {
                //--[ Localize Font Object ]----------
                                #if TextMeshPro_Pre53
                TMPro.TextMeshProFont newFont = GetSecondaryTranslatedObj <TMPro.TextMeshProFont>(ref MainTranslation, ref SecondaryTranslation);
                                #else
                TMPro.TMP_FontAsset newFont = GetSecondaryTranslatedObj <TMPro.TMP_FontAsset>(ref MainTranslation, ref SecondaryTranslation);
                                #endif

                if (newFont != null)
                {
                    if (mTarget_TMPUGUILabel.font != newFont)
                    {
                        mTarget_TMPUGUILabel.font = newFont;
                    }
                }
                else
                {
                    //--[ Localize Font Material ]----------
                    Material newMat = GetSecondaryTranslatedObj <Material>(ref MainTranslation, ref SecondaryTranslation);
                    if (newMat != null && mTarget_TMPUGUILabel.fontMaterial != newMat)
                    {
                        if (!newMat.name.StartsWith(mTarget_TMPUGUILabel.font.name))
                        {
                            newFont = GetTMPFontFromMaterial(newMat.name);
                            if (newFont != null)
                            {
                                mTarget_TMPUGUILabel.font = newFont;
                            }
                        }
                        mTarget_TMPUGUILabel.fontSharedMaterial = newMat;
                    }
                }
            }
            if (mInitializeAlignment)
            {
                mInitializeAlignment = false;
                InitAlignment_TMPro(mTarget_TMPUGUILabel.alignment, out mAlignmentTMPro_LTR, out mAlignmentTMPro_RTL);
            }
            if (!string.IsNullOrEmpty(MainTranslation) && mTarget_TMPUGUILabel.text != MainTranslation)
            {
                if (Localize.CurrentLocalizeComponent.CorrectAlignmentForRTL)
                {
                    mTarget_TMPUGUILabel.alignment = LocalizationManager.IsRight2Left ? mAlignmentTMPro_RTL : mAlignmentTMPro_LTR;
                }

                mTarget_TMPUGUILabel.text = MainTranslation;
                //mTarget_TMPUGUILabel.SetText(MainTranslation, 0);
            }
        }
        public void DoLocalize_TMPLabel(string MainTranslation, string SecondaryTranslation)
        {
            // there its a problem with TMPro that disables and renables the inspector when changing fonts, and that breaks the current preview flow
            if (!Application.isPlaying)
            {
                                #if UNITY_EDITOR
                if (UnityEditor.Selection.activeGameObject == gameObject)
                {
                    if (string.IsNullOrEmpty(TMP_previewLanguage))
                    {
                        TMP_previewLanguage = LocalizationManager.CurrentLanguage;
                    }
                }
                                #endif
            }

            //--[ Localize Font Object ]----------
            {
                                #if TextMeshPro_Pre53
                TMPro.TextMeshProFont newFont = GetSecondaryTranslatedObj <TMPro.TextMeshProFont>(ref MainTranslation, ref SecondaryTranslation);
                                #else
                TMPro.TMP_FontAsset newFont = GetSecondaryTranslatedObj <TMPro.TMP_FontAsset>(ref MainTranslation, ref SecondaryTranslation);
                                #endif


                if (newFont != null)
                {
                    if (mTarget_TMPLabel.font != newFont)
                    {
                        mTarget_TMPLabel.font = newFont;
                    }
                }
                else
                {
                    //--[ Localize Font Material ]----------
                    Material newMat = GetSecondaryTranslatedObj <Material>(ref MainTranslation, ref SecondaryTranslation);
                    if (newMat != null && mTarget_TMPLabel.fontMaterial != newMat)
                    {
                        mTarget_TMPLabel.fontMaterial = newMat;
                    }
                }
            }
            if (mInitializeAlignment)
            {
                mInitializeAlignment    = false;
                mOriginalAlignmentTMPro = mTarget_TMPLabel.alignment;
            }

            if (!string.IsNullOrEmpty(MainTranslation) && mTarget_TMPLabel.text != MainTranslation)
            {
                if (Localize.CurrentLocalizeComponent.CorrectAlignmentForRTL)
                {
                    if (mTarget_TMPLabel.alignment <= TMPro.TextAlignmentOptions.TopJustified)
                    {
                        mTarget_TMPLabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.TopRight : mOriginalAlignmentTMPro;
                    }
                    else
                    if (mTarget_TMPLabel.alignment <= TMPro.TextAlignmentOptions.Justified)
                    {
                        mTarget_TMPLabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.Right : mOriginalAlignmentTMPro;
                    }
                    else
                    {
                        mTarget_TMPLabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.BottomRight : mOriginalAlignmentTMPro;
                    }
                }

                mTarget_TMPLabel.text = MainTranslation;
                mTarget_TMPLabel.SetText(MainTranslation, 0);
            }
        }
예제 #4
0
        public void DoLocalize_TMPLabel(string MainTranslation, string SecondaryTranslation)
        {
            // there its a problem with TMPro that disables and renables the inspector when changing fonts, and that breaks the current preview flow
            if (!Application.isPlaying)
            {
                                #if UNITY_EDITOR
                if (UnityEditor.Selection.activeGameObject == gameObject)
                {
                    if (string.IsNullOrEmpty(TMP_previewLanguage))
                    {
                        TMP_previewLanguage = LocalizationManager.CurrentLanguage;
                    }
                }
                                #endif
            }

            //--[ Localize Font Object ]----------
            {
                                #if TextMeshPro_Pre53
                TMPro.TextMeshProFont newFont = GetSecondaryTranslatedObj <TMPro.TextMeshProFont>(ref MainTranslation, ref SecondaryTranslation);
                                #else
                TMPro.TMP_FontAsset newFont = GetSecondaryTranslatedObj <TMPro.TMP_FontAsset>(ref MainTranslation, ref SecondaryTranslation);
                                #endif


                if (newFont != null)
                {
                    if (mTarget_TMPLabel.font != newFont)
                    {
                        mTarget_TMPLabel.font = newFont;
                    }
                }
                else
                {
                    //--[ Localize Font Material ]----------
                    Material newMat = GetSecondaryTranslatedObj <Material>(ref MainTranslation, ref SecondaryTranslation);
                    if (newMat != null && mTarget_TMPLabel.fontMaterial != newMat)
                    {
                        if (!newMat.name.StartsWith(mTarget_TMPLabel.font.name))
                        {
                            newFont = GetTMPFontFromMaterial(newMat.name);
                            if (newFont != null)
                            {
                                mTarget_TMPLabel.font = newFont;
                            }
                        }

                        mTarget_TMPLabel.fontSharedMaterial /* fontMaterial*/ = newMat;
                    }
                }
            }
            if (mInitializeAlignment)
            {
                mInitializeAlignment = false;
                InitAlignment_TMPro(mTarget_TMPLabel.alignment, out mAlignmentTMPro_LTR, out mAlignmentTMPro_RTL);
            }

            if (!string.IsNullOrEmpty(MainTranslation) && mTarget_TMPLabel.text != MainTranslation)
            {
                if (Localize.CurrentLocalizeComponent.CorrectAlignmentForRTL)
                {
                    mTarget_TMPLabel.alignment = LocalizationManager.IsRight2Left ? mAlignmentTMPro_RTL : mAlignmentTMPro_LTR;
                }

                mTarget_TMPLabel.text = MainTranslation;
                //mTarget_TMPLabel.SetText( MainTranslation, 0 );
            }
        }
예제 #5
0
        public void DoLocalize_TMPLabel(string mainTranslation, string secondaryTranslation)
        {
            // there its a problem with TMPro that disables and renables the inspector when changing fonts, and that breaks the current preview flow
            if (!Application.isPlaying)
            {
                                #if UNITY_EDITOR
                if (UnityEditor.Selection.activeGameObject == gameObject)
                {
                    if (string.IsNullOrEmpty(TMP_previewLanguage))
                    {
                        TMP_previewLanguage = LocalizationManager.CurrentLanguage;
                    }
                }
                                #endif
            }

            //--[ Localize Font Object ]----------
            {
                                #if TextMeshPro_Pre53
                TMPro.TextMeshProFont newFont = GetSecondaryTranslatedObj <TMPro.TextMeshProFont>(ref mainTranslation, ref secondaryTranslation);
                                #else
                TMPro.TMP_FontAsset newFont = GetSecondaryTranslatedObj <TMPro.TMP_FontAsset>(ref mainTranslation, ref secondaryTranslation);
                                #endif


                if (newFont != null)
                {
                    if (mTarget_TMPLabel.font != newFont)
                    {
                        mTarget_TMPLabel.font = newFont;
                    }
                }
                else
                {
                    //--[ Localize Font Material ]----------
                    Material newMat = GetSecondaryTranslatedObj <Material>(ref mainTranslation, ref secondaryTranslation);
                    if (newMat != null && mTarget_TMPLabel.fontMaterial != newMat)
                    {
                        if (!newMat.name.StartsWith(mTarget_TMPLabel.font.name, StringComparison.Ordinal))
                        {
                            newFont = GetTMPFontFromMaterial(secondaryTranslation.EndsWith(newMat.name, StringComparison.Ordinal) ? secondaryTranslation : newMat.name);
                            if (newFont != null)
                            {
                                mTarget_TMPLabel.font = newFont;
                            }
                        }

                        mTarget_TMPLabel.fontSharedMaterial = newMat;
                    }
                }
            }
            if (mInitializeAlignment)
            {
                mInitializeAlignment = false;
                mAlignmentTMPwasRTL  = LocalizationManager.IsRight2Left;
                InitAlignment_TMPro(mAlignmentTMPwasRTL, mTarget_TMPLabel.alignment, out mAlignmentTMPro_LTR, out mAlignmentTMPro_RTL);
            }
            else
            {
                TMPro.TextAlignmentOptions alignRTL, alignLTR;
                InitAlignment_TMPro(mAlignmentTMPwasRTL, mTarget_TMPLabel.alignment, out alignLTR, out alignRTL);

                if ((mAlignmentTMPwasRTL && mAlignmentTMPro_RTL != alignRTL) ||
                    (!mAlignmentTMPwasRTL && mAlignmentTMPro_LTR != alignLTR))
                {
                    mAlignmentTMPro_LTR = alignLTR;
                    mAlignmentTMPro_RTL = alignRTL;
                }
                mAlignmentTMPwasRTL = LocalizationManager.IsRight2Left;
            }

            if (mainTranslation != null && mTarget_TMPLabel.text != mainTranslation)
            {
                if (CurrentLocalizeComponent.CorrectAlignmentForRTL)
                {
                    mTarget_TMPLabel.alignment         = LocalizationManager.IsRight2Left ? mAlignmentTMPro_RTL : mAlignmentTMPro_LTR;
                    mTarget_TMPLabel.isRightToLeftText = LocalizationManager.IsRight2Left;
                    if (LocalizationManager.IsRight2Left)
                    {
                        mainTranslation = ReverseText(mainTranslation);
                    }
                }

                mTarget_TMPLabel.text = mainTranslation;
                //mTarget_TMPLabel.SetText( mainTranslation, 0 );
            }
        }
예제 #6
0
        public void DoLocalize_TMPUGUILabel(string mainTranslation, string secondaryTranslation)
        {
            {
                //--[ Localize Font Object ]----------
                                #if TextMeshPro_Pre53
                TMPro.TextMeshProFont newFont = GetSecondaryTranslatedObj <TMPro.TextMeshProFont>(ref mainTranslation, ref secondaryTranslation);
                                #else
                TMPro.TMP_FontAsset newFont = GetSecondaryTranslatedObj <TMPro.TMP_FontAsset>(ref mainTranslation, ref secondaryTranslation);
                                #endif

                if (newFont != null)
                {
                    if (mTarget_TMPUGUILabel.font != newFont)
                    {
                        mTarget_TMPUGUILabel.font = newFont;
                    }
                }
                else
                {
                    //--[ Localize Font Material ]----------
                    Material newMat = GetSecondaryTranslatedObj <Material>(ref mainTranslation, ref secondaryTranslation);
                    if (newMat != null && mTarget_TMPUGUILabel.fontMaterial != newMat)
                    {
                        if (!newMat.name.StartsWith(mTarget_TMPUGUILabel.font.name, StringComparison.Ordinal))
                        {
                            newFont = GetTMPFontFromMaterial(secondaryTranslation.EndsWith(newMat.name, StringComparison.Ordinal) ? secondaryTranslation : newMat.name);
                            if (newFont != null)
                            {
                                mTarget_TMPUGUILabel.font = newFont;
                            }
                        }
                        mTarget_TMPUGUILabel.fontSharedMaterial = newMat;
                    }
                }
            }

            if (mInitializeAlignment)
            {
                mInitializeAlignment = false;
                mAlignmentTMPwasRTL  = LocalizationManager.IsRight2Left;
                InitAlignment_TMPro(mAlignmentTMPwasRTL, mTarget_TMPUGUILabel.alignment, out mAlignmentTMPro_LTR, out mAlignmentTMPro_RTL);
            }
            else
            {
                TMPro.TextAlignmentOptions alignRTL, alignLTR;
                InitAlignment_TMPro(mAlignmentTMPwasRTL, mTarget_TMPUGUILabel.alignment, out alignLTR, out alignRTL);

                if ((mAlignmentTMPwasRTL && mAlignmentTMPro_RTL != alignRTL) ||
                    (!mAlignmentTMPwasRTL && mAlignmentTMPro_LTR != alignLTR))
                {
                    mAlignmentTMPro_LTR = alignLTR;
                    mAlignmentTMPro_RTL = alignRTL;
                }
                mAlignmentTMPwasRTL = LocalizationManager.IsRight2Left;
            }

            if (mainTranslation != null && mTarget_TMPUGUILabel.text != mainTranslation)
            {
                if (CurrentLocalizeComponent.CorrectAlignmentForRTL)
                {
                    mTarget_TMPUGUILabel.alignment         = LocalizationManager.IsRight2Left ? mAlignmentTMPro_RTL : mAlignmentTMPro_LTR;
                    mTarget_TMPUGUILabel.isRightToLeftText = LocalizationManager.IsRight2Left;
                    if (LocalizationManager.IsRight2Left)
                    {
                        mainTranslation = ReverseText(mainTranslation);
                    }
                }

                mTarget_TMPUGUILabel.text = mainTranslation;
                //mTarget_TMPUGUILabel.SetText(mainTranslation, 0);
            }
        }