public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label) { var termRect = rect; termRect.xMax -= 50; var termProp = property.FindPropertyRelative("mTerm"); TermsPopup_Drawer.ShowGUI(termRect, termProp, label, null); var maskRect = rect; maskRect.xMin = maskRect.xMax - 30; var termIgnoreRTL = property.FindPropertyRelative("mRTL_IgnoreArabicFix"); var termConvertNumbers = property.FindPropertyRelative("mRTL_ConvertNumbers"); int mask = (termIgnoreRTL.boolValue ? 0 : 1) + (termConvertNumbers.boolValue ? 0 : 2); int newMask = EditorGUI.MaskField(maskRect, mask, new string[] { "Arabic Fix", "Ignore Numbers in RTL" }); if (newMask != mask) { termIgnoreRTL.boolValue = (newMask & 1) == 0; termConvertNumbers.boolValue = (newMask & 2) == 0; } var showRect = rect; showRect.xMin = termRect.xMax; showRect.xMax = maskRect.xMin; bool enabled = GUI.enabled; GUI.enabled = enabled & (!string.IsNullOrEmpty(termProp.stringValue) && termProp.stringValue != "-"); if (GUI.Button(showRect, "?")) { var source = LocalizationManager.GetSourceContaining(termProp.stringValue); LocalizationEditor.mKeyToExplore = termProp.stringValue; Selection.activeObject = source; } GUI.enabled = enabled; }
void OnEnable() { mLocalize = (Localize)target; mProp_mTerm = serializedObject.FindProperty("mTerm"); mProp_mTermSecondary = serializedObject.FindProperty("mTermSecondary"); mProp_TranslatedObjects = serializedObject.FindProperty("TranslatedObjects"); mProp_IgnoreRTL = serializedObject.FindProperty("IgnoreRTL"); mProp_SeparateWords = serializedObject.FindProperty("AddSpacesToJoinedLanguages"); mProp_MaxCharactersInRTL = serializedObject.FindProperty("MaxCharactersInRTL"); mProp_IgnoreNumbersInRTL = serializedObject.FindProperty("IgnoreNumbersInRTL"); mProp_CorrectAlignmentForRTL = serializedObject.FindProperty("CorrectAlignmentForRTL"); mProp_LocalizeOnAwake = serializedObject.FindProperty("LocalizeOnAwake"); mProp_AlwaysForceLocalize = serializedObject.FindProperty("AlwaysForceLocalize"); mProp_TermSuffix = serializedObject.FindProperty("TermSuffix"); mProp_TermPrefix = serializedObject.FindProperty("TermPrefix"); // Check Copy/Paste Localize component into another gameObject if (mLocalize.mTarget != null) { var cmp = mLocalize.mTarget as Component; if (cmp != null && cmp.gameObject != mLocalize.gameObject) { serializedObject.ApplyModifiedProperties(); mLocalize.ReleaseTarget(); serializedObject.Update(); } } if (LocalizationManager.Sources.Count == 0) { LocalizationManager.UpdateSources(); } //LocalizationEditor.ParseTerms (true); //mGUI_ShowReferences = (mLocalize.TranslatedObjects!=null && mLocalize.TranslatedObjects.Length>0); //mGUI_ShowCallback = (mLocalize.LocalizeCallBack.Target!=null); //mGUI_ShowTems = true; LocalizationEditor.mKeysDesc_AllowEdit = false; GUI_SelectedTerm = 0; mNewKeyName = mLocalize.Term; if (mLocalize.Source != null) { LocalizationEditor.mLanguageSource = mLocalize.Source; } else { if (LocalizationManager.Sources.Count == 0) { LocalizationManager.UpdateSources(); } LocalizationEditor.mLanguageSource = LocalizationManager.GetSourceContaining(mLocalize.Term); } //UpgradeManager.EnablePlugins(); LocalizationEditor.ApplyInferredTerm(mLocalize); }
void OnEnable() { mLocalize = (Localize)target; mLocalizeInspector = this; LocalizationEditor.mCurrentInspector = this; mProp_mTerm = serializedObject.FindProperty("mTerm"); mProp_mTermSecondary = serializedObject.FindProperty("mTermSecondary"); mProp_TranslatedObjects = serializedObject.FindProperty("TranslatedObjects"); mProp_IgnoreRTL = serializedObject.FindProperty("IgnoreRTL"); mProp_SeparateWords = serializedObject.FindProperty("AddSpacesToJoinedLanguages"); mProp_MaxCharactersInRTL = serializedObject.FindProperty("MaxCharactersInRTL"); mProp_IgnoreNumbersInRTL = serializedObject.FindProperty("IgnoreNumbersInRTL"); mProp_CorrectAlignmentForRTL = serializedObject.FindProperty("CorrectAlignmentForRTL"); mProp_LocalizeOnAwake = serializedObject.FindProperty("LocalizeOnAwake"); mProp_AlwaysForceLocalize = serializedObject.FindProperty("AlwaysForceLocalize"); mProp_TermSuffix = serializedObject.FindProperty("TermSuffix"); mProp_TermPrefix = serializedObject.FindProperty("TermPrefix"); mProp_CallbackEvent = serializedObject.FindProperty("LocalizeEvent"); mProp_AllowLocalizedParameters = serializedObject.FindProperty("AllowLocalizedParameters"); mProp_AllowParameters = serializedObject.FindProperty("AllowParameters"); if (LocalizationManager.Sources.Count == 0) { LocalizationManager.UpdateSources(); } //LocalizationEditor.ParseTerms (true); //mGUI_ShowReferences = (mLocalize.TranslatedObjects!=null && mLocalize.TranslatedObjects.Length>0); //mGUI_ShowCallback = (mLocalize.LocalizeCallBack.Target!=null); //mGUI_ShowTems = true; LocalizationEditor.mKeysDesc_AllowEdit = false; GUI_SelectedTerm = 0; mNewKeyName = mLocalize.Term; if (mLocalize.Source != null) { LocalizationEditor.mLanguageSource = mLocalize.Source.SourceData; } else { if (LocalizationManager.Sources.Count == 0) { LocalizationManager.UpdateSources(); } LocalizationEditor.mLanguageSource = LocalizationManager.GetSourceContaining(mLocalize.Term); } //UpgradeManager.EnablePlugins(); LocalizationEditor.ApplyInferredTerm(mLocalize); RemoveUnusedReferences(mLocalize); }
void OnGUI_Source() { GUILayout.BeginHorizontal(); LanguageSource currentSource = mLocalize.Source; if (currentSource == null) { currentSource = LocalizationManager.GetSourceContaining(mLocalize.Term); } if (GUILayout.Button("Open Source", EditorStyles.toolbarButton, GUILayout.Width(100))) { Selection.activeObject = currentSource; string sTerm, sSecondary; mLocalize.GetFinalTerms(out sTerm, out sSecondary); if (GUI_SelectedTerm == 1) { sTerm = sSecondary; } LocalizationEditor.mKeyToExplore = sTerm; } GUILayout.Space(2); GUILayout.BeginHorizontal(EditorStyles.toolbar); EditorGUI.BeginChangeCheck(); if (!mLocalize.Source) { GUI.contentColor = Color.Lerp(Color.gray, Color.yellow, 0.1f); } LanguageSource NewSource = EditorGUILayout.ObjectField(currentSource, typeof(LanguageSource), true) as LanguageSource; GUI.contentColor = Color.white; if (EditorGUI.EndChangeCheck()) { mLocalize.Source = NewSource; } GUILayout.EndHorizontal(); GUILayout.EndHorizontal(); }
void OnGUI_Source() { GUILayout.BeginHorizontal(); ILanguageSource currentSource = mLocalize.Source; if (currentSource == null) { LanguageSourceData source = LocalizationManager.GetSourceContaining(mLocalize.Term); currentSource = source == null ? null : source.owner; } if (GUILayout.Button("Open Source", EditorStyles.toolbarButton, GUILayout.Width(100))) { Selection.activeObject = currentSource as UnityEngine.Object; string sTerm, sSecondary; mLocalize.GetFinalTerms(out sTerm, out sSecondary); if (GUI_SelectedTerm == 1) { sTerm = sSecondary; } LocalizationEditor.mKeyToExplore = sTerm; } GUILayout.Space(2); GUILayout.BeginHorizontal(EditorStyles.toolbar); EditorGUI.BeginChangeCheck(); if (mLocalize.Source == null) { GUI.contentColor = Color.Lerp(Color.gray, Color.yellow, 0.1f); } Object obj = EditorGUILayout.ObjectField(currentSource as Object, typeof(Object), true); GUI.contentColor = Color.white; if (EditorGUI.EndChangeCheck()) { ILanguageSource NewSource = obj as ILanguageSource; if (NewSource == null && (obj as GameObject != null)) { NewSource = (obj as GameObject).GetComponent <LanguageSource>(); } mLocalize.Source = NewSource; string sTerm, sSecondary; mLocalize.GetFinalTerms(out sTerm, out sSecondary); if (GUI_SelectedTerm == 1) { sTerm = sSecondary; } UpdateTermsList(sTerm); } if (GUILayout.Button(new GUIContent("Detect", "Finds the LanguageSource containing the selected term, the term list will now only show terms inside that source."), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { string sTerm, sSecondary; mLocalize.GetFinalTerms(out sTerm, out sSecondary); if (GUI_SelectedTerm == 1) { sTerm = sSecondary; } var data = LocalizationManager.GetSourceContaining(sTerm, false); mLocalize.Source = data == null ? null : data.owner; mTermsArray = null; } GUILayout.EndHorizontal(); GUILayout.EndHorizontal(); }
bool OnGUI_SelectKey(ref string Term, bool Inherited) // Inherited==true means that the mTerm is empty and we are using the Label.text instead { GUILayout.Space(5); GUILayout.BeginHorizontal(); GUI.changed = false; mAllowEditKeyName = GUILayout.Toggle(mAllowEditKeyName, "Term:", EditorStyles.foldout, GUILayout.ExpandWidth(false)); if (GUI.changed && mAllowEditKeyName) { mNewKeyName = Term; mTermsArray = null; } bool bChanged = false; if (mTermsArray == null || (Term != "-" && System.Array.IndexOf(mTermsArray, Term) < 0)) { UpdateTermsList(Term); } if (Inherited) { GUI.contentColor = Color.Lerp(Color.gray, Color.yellow, 0.1f); } int Index = (Term == "-" || Term == "") ? mTermsArray.Length - 1 : System.Array.IndexOf(mTermsArray, Term); GUI.changed = false; int newIndex = EditorGUILayout.Popup(Index, mTermsArray); GUI.contentColor = Color.white; if (/*newIndex != Index && newIndex>=0*/ GUI.changed) { GUI.changed = false; if (mLocalize.Source != null && newIndex == mTermsArray.Length - 4) //< show terms from all sources > { mLocalize.Source = null; mTermsArray = null; } else if (newIndex == mTermsArray.Length - 2) //<inferred from text> { mNewKeyName = Term = string.Empty; } else if (newIndex == mTermsArray.Length - 1) //<none> { mNewKeyName = Term = "-"; } else { mNewKeyName = Term = mTermsArray[newIndex]; } if (GUI_SelectedTerm == 0) { mLocalize.SetTerm(mNewKeyName); } else { mLocalize.SetTerm(null, mNewKeyName); } mAllowEditKeyName = false; bChanged = true; } LanguageSourceData source = LocalizationManager.GetSourceContaining(Term); TermData termData = source.GetTermData(Term); if (termData != null) { if (Inherited) { bChanged = true; // if the term its inferred and a matching term its found, then use that } eTermType NewType = (eTermType)EditorGUILayout.EnumPopup(termData.TermType, GUILayout.Width(90)); if (termData.TermType != NewType) { termData.TermType = NewType; } } GUILayout.EndHorizontal(); if (mAllowEditKeyName) { GUILayout.BeginHorizontal(GUILayout.Height(1)); GUILayout.BeginHorizontal(EditorStyles.toolbar); if (mNewKeyName == null) { mNewKeyName = string.Empty; } GUI.changed = false; mNewKeyName = EditorGUILayout.TextField(mNewKeyName, new GUIStyle("ToolbarSeachTextField"), GUILayout.ExpandWidth(true)); if (GUI.changed) { mTermsArray = null; // regenerate this array to apply filtering GUI.changed = false; } if (GUILayout.Button(string.Empty, string.IsNullOrEmpty(mNewKeyName) ? "ToolbarSeachCancelButtonEmpty" : "ToolbarSeachCancelButton", GUILayout.ExpandWidth(false))) { mTermsArray = null; // regenerate this array to apply filtering mNewKeyName = string.Empty; } GUILayout.EndHorizontal(); string ValidatedName = mNewKeyName; LanguageSourceData.ValidateFullTerm(ref ValidatedName); bool CanUseNewName = (source.GetTermData(ValidatedName) == null); GUI.enabled = (!string.IsNullOrEmpty(mNewKeyName) && CanUseNewName); if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { mNewKeyName = ValidatedName; mTermsArray = null; // this recreates that terms array LanguageSourceData Source = null; #if UNITY_EDITOR if (mLocalize.Source != null) { Source = mLocalize.Source.SourceData; } #endif if (Source == null) { Source = LocalizationManager.Sources[0]; } Term = mNewKeyName; var data = Source.AddTerm(mNewKeyName, eTermType.Text, false); if (data.Languages.Length > 0) { data.Languages[0] = mLocalize.GetMainTargetsText(); } Source.Editor_SetDirty(); AssetDatabase.SaveAssets(); mAllowEditKeyName = false; bChanged = true; GUIUtility.keyboardControl = 0; } GUI.enabled = (termData != null && !string.IsNullOrEmpty(mNewKeyName) && CanUseNewName); if (GUILayout.Button(new GUIContent("Rename", "Renames the term in the source and updates every object using it in the current scene"), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { mNewKeyName = ValidatedName; Term = mNewKeyName; mTermsArray = null; // this recreates that terms array mAllowEditKeyName = false; bChanged = true; LocalizationEditor.TermReplacements = new Dictionary <string, string>(System.StringComparer.Ordinal); LocalizationEditor.TermReplacements[termData.Term] = mNewKeyName; termData.Term = mNewKeyName; source.UpdateDictionary(true); LocalizationEditor.ReplaceTermsInCurrentScene(); GUIUtility.keyboardControl = 0; EditorApplication.update += LocalizationEditor.DoParseTermsInCurrentScene; } GUI.enabled = true; GUILayout.EndHorizontal(); bChanged |= OnGUI_SelectKey_PreviewTerms(ref Term); } GUILayout.Space(5); return(bChanged); }
// this method shows the key description and the localization to each language public static TermData OnGUI_Keys_Languages(string Key, Localize localizeCmp, bool IsPrimaryKey = true) { if (Key == null) { Key = string.Empty; } TermData termdata = null; LanguageSource source = (localizeCmp == null ? mLanguageSource : localizeCmp.Source); if (source == null) { source = LocalizationManager.GetSourceContaining(Key, false); } if (source == null) { if (localizeCmp == null) { source = LocalizationManager.Sources[0]; } else { source = LocalizationManager.GetSourceContaining(IsPrimaryKey ? localizeCmp.SecondaryTerm : localizeCmp.Term, true); } } if (string.IsNullOrEmpty(Key)) { EditorGUILayout.HelpBox("Select a Term to Localize", MessageType.Info); return(null); } else { termdata = source.GetTermData(Key); if (termdata == null && localizeCmp != null) { var realSource = LocalizationManager.GetSourceContaining(Key, false); if (realSource != null) { termdata = realSource.GetTermData(Key); source = realSource; } } if (termdata == null) { if (Key == "-") { return(null); } EditorGUILayout.HelpBox(string.Format("Key '{0}' is not Localized or it is in a different Language Source", Key), MessageType.Error); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Add Term to Source")) { var termType = eTermType.Text; if (localizeCmp != null && localizeCmp.mLocalizeTarget != null) { termType = IsPrimaryKey ? localizeCmp.mLocalizeTarget.GetPrimaryTermType(localizeCmp) : localizeCmp.mLocalizeTarget.GetSecondaryTermType(localizeCmp); } AddTerm(Key, true, termType); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); return(null); } } //--[ Type ]---------------------------------- if (localizeCmp == null) { GUILayout.BeginHorizontal(); GUILayout.Label("Type:", GUILayout.ExpandWidth(false)); eTermType NewType = (eTermType)EditorGUILayout.EnumPopup(termdata.TermType, GUILayout.ExpandWidth(true)); if (termdata.TermType != NewType) { termdata.TermType = NewType; } GUILayout.EndHorizontal(); } //--[ Description ]--------------------------- mKeysDesc_AllowEdit = GUILayout.Toggle(mKeysDesc_AllowEdit, "Description", EditorStyles.foldout, GUILayout.ExpandWidth(true)); if (mKeysDesc_AllowEdit) { string NewDesc = EditorGUILayout.TextArea(termdata.Description, Style_WrapTextField); if (NewDesc != termdata.Description) { termdata.Description = NewDesc; EditorUtility.SetDirty(source); } } else { EditorGUILayout.HelpBox(string.IsNullOrEmpty(termdata.Description) ? "No description" : termdata.Description, MessageType.Info); } OnGUI_Keys_Language_SpecializationsBar(); OnGUI_Keys_Languages(Key, ref termdata, localizeCmp, IsPrimaryKey, source); return(termdata); }
void OnGUI_Source() { GUILayout.BeginHorizontal(); LanguageSource currentSource = mLocalize.Source; if (currentSource == null) { currentSource = LocalizationManager.GetSourceContaining(mLocalize.Term); } if (GUILayout.Button("Open Source", EditorStyles.toolbarButton, GUILayout.Width(100))) { Selection.activeObject = currentSource; string sTerm, sSecondary; mLocalize.GetFinalTerms(out sTerm, out sSecondary); if (GUI_SelectedTerm == 1) { sTerm = sSecondary; } LocalizationEditor.mKeyToExplore = sTerm; } GUILayout.Space(2); GUILayout.BeginHorizontal(EditorStyles.toolbar); EditorGUI.BeginChangeCheck(); if (!mLocalize.Source) { GUI.contentColor = Color.Lerp(Color.gray, Color.yellow, 0.1f); } LanguageSource NewSource = EditorGUILayout.ObjectField(currentSource, typeof(LanguageSource), true) as LanguageSource; GUI.contentColor = Color.white; if (EditorGUI.EndChangeCheck()) { mLocalize.Source = NewSource; string sTerm, sSecondary; mLocalize.GetFinalTerms(out sTerm, out sSecondary); if (GUI_SelectedTerm == 1) { sTerm = sSecondary; } UpdateTermsList(sTerm); } if (GUILayout.Button(new GUIContent("Detect", "Finds the LanguageSource containing the selected term, the term list will now only show terms inside that source."), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { string sTerm, sSecondary; mLocalize.GetFinalTerms(out sTerm, out sSecondary); if (GUI_SelectedTerm == 1) { sTerm = sSecondary; } mLocalize.Source = LocalizationManager.GetSourceContaining(sTerm, false); mTermsArray = null; } GUILayout.EndHorizontal(); GUILayout.EndHorizontal(); }
// this method shows the key description and the localization to each language public static void OnGUI_Keys_Languages(string Key, Localize localizeCmp, bool IsPrimaryKey = true) { if (Key == null) { Key = string.Empty; } TermData termdata = null; LanguageSource source = (localizeCmp == null ? mLanguageSource : localizeCmp.Source); if (source == null) { source = LocalizationManager.GetSourceContaining(Key, false); } if (source == null) { if (localizeCmp == null) { source = LocalizationManager.Sources[0]; } else { source = LocalizationManager.GetSourceContaining(IsPrimaryKey ? localizeCmp.SecondaryTerm : localizeCmp.Term, true); } } if (string.IsNullOrEmpty(Key)) { EditorGUILayout.HelpBox("Select a Term to Localize", UnityEditor.MessageType.Info); return; } else { termdata = source.GetTermData(Key); if (termdata == null && localizeCmp != null) { var realSource = LocalizationManager.GetSourceContaining(Key, false); if (realSource != null) { termdata = realSource.GetTermData(Key); source = realSource; } } if (termdata == null) { EditorGUILayout.HelpBox(string.Format("Key '{0}' is not Localized or it is in a different Language Source", Key), UnityEditor.MessageType.Error); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Add Term to Source")) { source.AddTerm(Key, eTermType.Text); GetParsedTerm(Key); SetAllTerms_When_InferredTerms_IsInSource(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); return; } } //--[ Type ]---------------------------------- if (localizeCmp == null) { GUILayout.BeginHorizontal(); GUILayout.Label("Type:", GUILayout.ExpandWidth(false)); eTermType NewType = (eTermType)EditorGUILayout.EnumPopup(termdata.TermType, GUILayout.ExpandWidth(true)); if (termdata.TermType != NewType) { termdata.TermType = NewType; } GUILayout.EndHorizontal(); } //--[ Description ]--------------------------- mKeysDesc_AllowEdit = GUILayout.Toggle(mKeysDesc_AllowEdit, "Description", EditorStyles.foldout, GUILayout.ExpandWidth(true)); if (mKeysDesc_AllowEdit) { string NewDesc = EditorGUILayout.TextArea(termdata.Description, LocalizationEditor.Style_WrapTextField); if (NewDesc != termdata.Description) { termdata.Description = NewDesc; EditorUtility.SetDirty(source); } } else { EditorGUILayout.HelpBox(string.IsNullOrEmpty(termdata.Description) ? "No description" : termdata.Description, UnityEditor.MessageType.Info); } OnGUI_Keys_Language_SpecializationsBar(); //--[ Languages ]--------------------------- GUILayout.BeginVertical("AS TextArea", GUILayout.Height(1)); OnGUI_Keys_LanguageTranslations(Key, localizeCmp, IsPrimaryKey, ref termdata, source); if (termdata.TermType == eTermType.Text) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Translate All", GUILayout.Width(85))) { string mainText = localizeCmp == null?LanguageSource.GetKeyFromFullTerm(Key) : localizeCmp.GetMainTargetsText(); for (int i = 0; i < source.mLanguages.Count; ++i) { if (string.IsNullOrEmpty(termdata.Languages[i])) { if (GUI_SelectedInputType == 0) { Translate(mainText, ref termdata, ref termdata.Languages[i], source.mLanguages[i].Code); termdata.Flags[i] |= (byte)TranslationFlag.AutoTranslated_Normal; } else { Translate(mainText, ref termdata, ref termdata.Languages_Touch[i], source.mLanguages[i].Code); termdata.Flags[i] |= (byte)TranslationFlag.AutoTranslated_Touch; } } } GUI.FocusControl(string.Empty); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
bool OnGUI_SelectKey(ref string Term, bool Inherited) // Inherited==true means that the mTerm is empty and we are using the Label.text instead { GUILayout.Space(5); GUILayout.BeginHorizontal(); bool bChanged = false; mAllowEditKeyName = GUILayout.Toggle(mAllowEditKeyName, "Term:", EditorStyles.foldout, GUILayout.ExpandWidth(false)); if (bChanged && mAllowEditKeyName) { mNewKeyName = Term; } bChanged = false; if (mTermsArray == null || System.Array.IndexOf(mTermsArray, Term) < 0) { UpdateTermsList(Term); } if (Inherited) { GUI.contentColor = Color.yellow * 0.8f; } int Index = System.Array.IndexOf(mTermsArray, Term); GUI.changed = false; int newIndex = EditorGUILayout.Popup(Index, mTermsArray); GUI.contentColor = Color.white; if (/*newIndex != Index && newIndex>=0*/ GUI.changed) { GUI.changed = false; mTermsArray [mTermsArray.Length - 1] = string.Empty; mNewKeyName = Term = mTermsArray[newIndex]; if (GUI_SelectedTerm == 0) { mLocalize.SetTerm(mNewKeyName); } else { mLocalize.SetTerm(null, mNewKeyName); } mAllowEditKeyName = false; bChanged = true; } LanguageSource source = LocalizationManager.GetSourceContaining(Term); TermData termData = source.GetTermData(Term); if (termData != null) { eTermType NewType = (eTermType)EditorGUILayout.EnumPopup(termData.TermType, GUILayout.Width(90)); if (termData.TermType != NewType) { termData.TermType = NewType; } } GUILayout.EndHorizontal(); if (mAllowEditKeyName) { GUILayout.BeginHorizontal(GUILayout.Height(1)); GUILayout.BeginHorizontal(EditorStyles.toolbar); if (mNewKeyName == null) { mNewKeyName = string.Empty; } GUI.changed = false; mNewKeyName = EditorGUILayout.TextField(mNewKeyName, new GUIStyle("ToolbarSeachTextField"), GUILayout.ExpandWidth(true)); if (GUI.changed) { mTermsArray = null; // regenerate this array to apply filtering GUI.changed = false; } if (GUILayout.Button(string.Empty, string.IsNullOrEmpty(mNewKeyName) ? "ToolbarSeachCancelButtonEmpty" : "ToolbarSeachCancelButton", GUILayout.ExpandWidth(false))) { mTermsArray = null; // regenerate this array to apply filtering mNewKeyName = string.Empty; } GUILayout.EndHorizontal(); string ValidatedName = mNewKeyName; LanguageSource.ValidateFullTerm(ref ValidatedName); bool CanUseNewName = (source.GetTermData(ValidatedName) == null); GUI.enabled = (!string.IsNullOrEmpty(mNewKeyName) && CanUseNewName); if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { mNewKeyName = ValidatedName; Term = mNewKeyName; mTermsArray = null; // this recreates that terms array LanguageSource Source = null; #if UNITY_EDITOR if (mLocalize.Source != null) { Source = mLocalize.Source; } #endif if (Source == null) { Source = LocalizationManager.Sources[0]; } Source.AddTerm(mNewKeyName, eTermType.Text); mAllowEditKeyName = false; bChanged = true; GUIUtility.keyboardControl = 0; } GUI.enabled = (termData != null && !string.IsNullOrEmpty(mNewKeyName) && CanUseNewName); if (GUILayout.Button(new GUIContent("Rename", "Renames the term in the source and updates every object using it in the current scene"), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { mNewKeyName = ValidatedName; Term = mNewKeyName; mTermsArray = null; // this recreates that terms array mAllowEditKeyName = false; bChanged = true; LocalizationEditor.TermReplacements = new Dictionary <string, string>(); LocalizationEditor.TermReplacements[termData.Term] = mNewKeyName; termData.Term = mNewKeyName; source.UpdateDictionary(true); LocalizationEditor.ReplaceTermsInCurrentScene(); GUIUtility.keyboardControl = 0; EditorApplication.update += LocalizationEditor.DoParseTermsInCurrentScene; } GUI.enabled = true; GUILayout.EndHorizontal(); bChanged |= OnGUI_SelectKey_PreviewTerms(ref Term); } GUILayout.Space(5); return(bChanged); }