Пример #1
0
        void OnGUI_Terms()
        {
            if (mLocalize.mGUI_ShowTems = GUITools.DrawHeader("Terms", mLocalize.mGUI_ShowTems))
            {
                //--[ tabs: Main and Secondary Terms ]----------------
                int oldTab = GUI_SelectedTerm;
                if (mLocalize.mLocalizeTarget != null && mLocalize.mLocalizeTarget.CanUseSecondaryTerm())
                {
                    GUI_SelectedTerm = GUITools.DrawTabs(GUI_SelectedTerm, new string[] { "Main", "Secondary" });
                }
                else
                {
                    GUI_SelectedTerm = 0;
                    GUITools.DrawTabs(GUI_SelectedTerm, new string[] { "Main", "" });
                }

                GUITools.BeginContents();

                TermData termData = null;

                if (GUI_SelectedTerm == 0)
                {
                    termData = OnGUI_PrimaryTerm(oldTab != GUI_SelectedTerm);
                }
                else
                {
                    termData = OnGUI_SecondaryTerm(oldTab != GUI_SelectedTerm);
                }

                GUITools.EndContents();

                //--[ Modifier ]-------------
                if (mLocalize.Term != "-" && termData != null && termData.TermType == eTermType.Text)
                {
                    EditorGUI.BeginChangeCheck();
                    int val = EditorGUILayout.Popup("Modifier", GUI_SelectedTerm == 0 ? (int)mLocalize.PrimaryTermModifier : (int)mLocalize.SecondaryTermModifier, System.Enum.GetNames(typeof(Localize.TermModification)));
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.FindProperty(GUI_SelectedTerm == 0 ? "PrimaryTermModifier" : "SecondaryTermModifier").enumValueIndex = val;
                        GUI.changed = false;
                    }

                    EditorGUI.BeginChangeCheck();
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Prefix:");
                    EditorGUILayout.PropertyField(mProp_TermPrefix, GUITools.EmptyContent);
                    GUILayout.Label("Suffix:");
                    EditorGUILayout.PropertyField(mProp_TermSuffix, GUITools.EmptyContent);
                    GUILayout.EndHorizontal();
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorApplication.delayCall += () =>
                        {
                            if (targets != null)
                            {
                                foreach (var t in targets)
                                {
                                    if ((t as Localize) != null)
                                    {
                                        (t as Localize).OnLocalize(true);
                                    }
                                }
                            }
                        };
                    }
                }


                //--[ OnAwake vs OnEnable ]-------------
                GUILayout.BeginHorizontal();
                mProp_LocalizeOnAwake.boolValue = GUILayout.Toggle(mProp_LocalizeOnAwake.boolValue, new GUIContent(" Pre-Localize on Awake", "Localizing on Awake could result in a lag when the level is loaded but faster later when objects are enabled. If false, it will Localize OnEnable, so will yield faster level load but could have a lag when screens are enabled"));
                GUILayout.FlexibleSpace();
                if (mLocalize.HasCallback())
                {
                    GUI.enabled = false;
                    GUILayout.Toggle(true, new GUIContent(" Force Localize", "Enable this when the translations have parameters (e.g. Thew winner is {[WINNER}]) to prevent any optimization that could prevent updating the translation when the object is enabled"));
                    GUI.enabled = true;
                }
                else
                {
                    mProp_AlwaysForceLocalize.boolValue = GUILayout.Toggle(mProp_AlwaysForceLocalize.boolValue, new GUIContent(" Force Localize", "Enable this when the translations have parameters (e.g. Thew winner is {[WINNER}]) to prevent any optimization that could prevent updating the translation when the object is enabled"));
                }
                GUILayout.EndHorizontal();

                //--[ Right To Left ]-------------
                if (mLocalize.Term != "-" && termData != null && termData.TermType == eTermType.Text)
                {
                    GUILayout.BeginVertical("Box");
                    GUILayout.BeginHorizontal();
                    mProp_IgnoreRTL.boolValue = GUILayout.Toggle(mProp_IgnoreRTL.boolValue, new GUIContent(" Ignore Right To Left", "Arabic and other RTL languages require processing them so they render correctly, this toogle allows ignoring that processing (in case you are doing it manually during a callback)"));
                    GUILayout.FlexibleSpace();
                    mProp_SeparateWords.boolValue = GUILayout.Toggle(mProp_SeparateWords.boolValue, new GUIContent(" Separate Words", " Some languages (e.g. Chinese, Japanese and Thai) don't add spaces to their words (all characters are placed toguether), enabling this checkbox, will add spaces to all characters to allow wrapping long texts into multiple lines."));
                    GUILayout.EndHorizontal();
                    if (!mLocalize.IgnoreRTL)
                    {
                        mProp_MaxCharactersInRTL.intValue = EditorGUILayout.IntField(new GUIContent("Max line length", "If the language is Right To Left, long lines will be split at this length and the RTL fix will be applied to each line, this should be set to the maximum number of characters that fit in this text width. 0 disables the per line fix"), mProp_MaxCharactersInRTL.intValue);
                        GUILayout.BeginHorizontal();
                        mProp_CorrectAlignmentForRTL.boolValue = GUILayout.Toggle(mProp_CorrectAlignmentForRTL.boolValue, new GUIContent(" Adjust Alignment", "Right-align when Right-To-Left Language, and Left-Align otherwise"));
                        GUILayout.FlexibleSpace();
                        mProp_IgnoreNumbersInRTL.boolValue = GUILayout.Toggle(mProp_IgnoreNumbersInRTL.boolValue, new GUIContent(" Ignore Numbers", "Preserve numbers as latin characters instead of converting them"));
                        GUILayout.EndHorizontal();
                    }

                    GUILayout.EndHorizontal();
                }


                //GUILayout.EndHorizontal();
            }
        }