void Export_Local(string File, eLocalSpreadsheeet CurrentExtension, eSpreadsheetUpdateMode UpdateMode) { try { serializedObject.ApplyModifiedProperties(); serializedObject.Update(); LocalizationEditor.ClearErrors(); string sPath = string.Empty; if (!System.IO.Path.IsPathRooted(File)) { File = string.Concat(Application.dataPath, "/", File); } try { sPath = System.IO.Path.GetDirectoryName(File); } catch (System.Exception) {} if (string.IsNullOrEmpty(sPath)) { sPath = Application.dataPath + "/"; } File = System.IO.Path.GetFileName(File); if (string.IsNullOrEmpty(File)) { File = "Localization.csv"; } if (Application.platform == RuntimePlatform.OSXEditor) { File = EditorUtility.SaveFilePanel("Select a CSV file renamed as TXT", sPath, File, "txt"); } else { File = EditorUtility.SaveFilePanel("Select a CSV or TXT file", sPath, File, "csv;*.txt"); } if (!string.IsNullOrEmpty(File)) { mLanguageSource.Spreadsheet_LocalFileName = TryMakingPathRelativeToProject(File); char Separator = mProp_Spreadsheet_LocalCSVSeparator.stringValue.Length > 0 ? mProp_Spreadsheet_LocalCSVSeparator.stringValue[0] : ','; var encoding = System.Text.Encoding.GetEncoding(mProp_Spreadsheet_LocalCSVEncoding.stringValue); if (encoding == null) { encoding = System.Text.Encoding.UTF8; } switch (CurrentExtension) { case eLocalSpreadsheeet.CSV: Export_CSV(File, UpdateMode, Separator, encoding); break; } } } catch (System.Exception) { LocalizationEditor.ShowError("Unable to export file\nCheck it is not READ-ONLY and that\nits not opened in an external viewer"); } }
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_MaxCharactersInRTL = serializedObject.FindProperty("MaxCharactersInRTL"); mProp_CorrectAlignmentForRTL = serializedObject.FindProperty("CorrectAlignmentForRTL"); mProp_LocalizeOnAwake = serializedObject.FindProperty("LocalizeOnAwake"); 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; } //UpgradeManager.EnablePlugins(); LocalizationEditor.ApplyInferredTerm(mLocalize); }
public void Custom_OnEnable(LanguageSourceData sourceData, SerializedProperty propSource) { bool ForceParse = (mLanguageSource != sourceData); mLanguageSource = sourceData; mLanguageSourceEditor = this; mCurrentInspector = this; if (!LocalizationManager.Sources.Contains(mLanguageSource)) { LocalizationManager.UpdateSources(); } mProp_Assets = propSource.FindPropertyRelative("Assets"); mProp_Languages = propSource.FindPropertyRelative("mLanguages"); mProp_Google_WebServiceURL = propSource.FindPropertyRelative("Google_WebServiceURL"); mProp_GoogleUpdateFrequency = propSource.FindPropertyRelative("GoogleUpdateFrequency"); mProp_GoogleUpdateSynchronization = propSource.FindPropertyRelative("GoogleUpdateSynchronization"); mProp_GoogleInEditorCheckFrequency = propSource.FindPropertyRelative("GoogleInEditorCheckFrequency"); mProp_GoogleUpdateDelay = propSource.FindPropertyRelative("GoogleUpdateDelay"); mProp_Google_SpreadsheetKey = propSource.FindPropertyRelative("Google_SpreadsheetKey"); mProp_Google_SpreadsheetName = propSource.FindPropertyRelative("Google_SpreadsheetName"); mProp_Google_Password = propSource.FindPropertyRelative("Google_Password"); mProp_CaseInsensitiveTerms = propSource.FindPropertyRelative("CaseInsensitiveTerms"); mProp_Spreadsheet_LocalFileName = propSource.FindPropertyRelative("Spreadsheet_LocalFileName"); mProp_Spreadsheet_LocalCSVSeparator = propSource.FindPropertyRelative("Spreadsheet_LocalCSVSeparator"); mProp_Spreadsheet_LocalCSVEncoding = propSource.FindPropertyRelative("Spreadsheet_LocalCSVEncoding"); mProp_Spreadsheet_SpecializationAsRows = propSource.FindPropertyRelative("Spreadsheet_SpecializationAsRows"); mProp_OnMissingTranslation = propSource.FindPropertyRelative("OnMissingTranslation"); mProp_AppNameTerm = propSource.FindPropertyRelative("mTerm_AppName"); mProp_IgnoreDeviceLanguage = propSource.FindPropertyRelative("IgnoreDeviceLanguage"); mProp_GoogleLiveSyncIsUptoDate = propSource.FindPropertyRelative("GoogleLiveSyncIsUptoDate"); mProp_AllowUnloadingLanguages = propSource.FindPropertyRelative("_AllowUnloadingLanguages"); if (!mIsParsing) { if (string.IsNullOrEmpty(mLanguageSource.Google_SpreadsheetKey)) { mSpreadsheetMode = eSpreadsheetMode.Local; } else { mSpreadsheetMode = eSpreadsheetMode.Google; } mCurrentViewMode = (mLanguageSource.mLanguages.Count > 0 ? eViewMode.Keys : eViewMode.Languages); UpdateSelectedKeys(); if (ForceParse || mParsedTerms.Count < mLanguageSource.mTerms.Count) { mSelectedCategories.Clear(); ParseTerms(true, false, true); } } ScheduleUpdateTermsToShowInList(); LoadSelectedCategories(); //UpgradeManager.EnablePlugins(); }
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() { var newSource = target as LanguageSource; bool ForceParse = (mLanguageSource != newSource); mLanguageSource = newSource; mLanguageSourceEditor = this; mCurrentInspector = this; if (!LocalizationManager.Sources.Contains(mLanguageSource)) { LocalizationManager.UpdateSources(); } mProp_Assets = serializedObject.FindProperty("Assets"); mProp_Languages = serializedObject.FindProperty("mLanguages"); mProp_Google_WebServiceURL = serializedObject.FindProperty("Google_WebServiceURL"); mProp_GoogleUpdateFrequency = serializedObject.FindProperty("GoogleUpdateFrequency"); mProp_GoogleInEditorCheckFrequency = serializedObject.FindProperty("GoogleInEditorCheckFrequency"); mProp_GoogleUpdateDelay = serializedObject.FindProperty("GoogleUpdateDelay"); mProp_Google_SpreadsheetKey = serializedObject.FindProperty("Google_SpreadsheetKey"); mProp_Google_SpreadsheetName = serializedObject.FindProperty("Google_SpreadsheetName"); mProp_CaseInsensitiveTerms = serializedObject.FindProperty("CaseInsensitiveTerms"); mProp_Spreadsheet_LocalFileName = serializedObject.FindProperty("Spreadsheet_LocalFileName"); mProp_Spreadsheet_LocalCSVSeparator = serializedObject.FindProperty("Spreadsheet_LocalCSVSeparator"); mProp_Spreadsheet_LocalCSVEncoding = serializedObject.FindProperty("Spreadsheet_LocalCSVEncoding"); mProp_Spreadsheet_SpecializationAsRows = serializedObject.FindProperty("Spreadsheet_SpecializationAsRows"); mProp_OnMissingTranslation = serializedObject.FindProperty("OnMissingTranslation"); mProp_AppNameTerm = serializedObject.FindProperty("mTerm_AppName"); mProp_IgnoreDeviceLanguage = serializedObject.FindProperty("IgnoreDeviceLanguage"); if (!mIsParsing) { if (string.IsNullOrEmpty(mLanguageSource.Google_SpreadsheetKey)) { mSpreadsheetMode = eSpreadsheetMode.Local; } else { mSpreadsheetMode = eSpreadsheetMode.Google; } mCurrentViewMode = (mLanguageSource.mLanguages.Count > 0 ? eViewMode.Keys : eViewMode.Languages); UpdateSelectedKeys(); if (ForceParse || mParsedTerms.Count < mLanguageSource.mTerms.Count) { mSelectedCategories.Clear(); ParseTerms(true); } } ScheduleUpdateTermsToShowInList(); LoadSelectedCategories(); //UpgradeManager.EnablePlugins(); }
void OnDisable() { //LocalizationManager.LocalizeAll(); SaveSelectedCategories(); mLanguageSourceEditor = null; if (mCurrentInspector == this) { mCurrentInspector = null; } }
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 Import_Local(string File, eLocalSpreadsheeet CurrentExtension, eSpreadsheetUpdateMode UpdateMode) { try { serializedObject.ApplyModifiedProperties(); serializedObject.Update(); LocalizationEditor.ClearErrors(); if (string.IsNullOrEmpty(File)) { File = Application.dataPath + "/Localization.csv"; } else if (!System.IO.Path.IsPathRooted(File)) { File = string.Concat(Application.dataPath, "/", File); } // On Mac there is an issue with previewing CSV files, so its forced to only TXT if (Application.platform == RuntimePlatform.OSXEditor) { File = EditorUtility.OpenFilePanel("Select a CSV file renamed as TXT", File, "txt"); } else { File = EditorUtility.OpenFilePanel("Select a CSV file or a CSV file renamed as TXT", File, "csv;*.txt"); } //File = EditorUtility.OpenFilePanel("Select CSV, XLS or XLSX File", File, "csv;*.xls;*.xlsx"); if (!string.IsNullOrEmpty(File)) { mLanguageSource.Spreadsheet_LocalFileName = TryMakingPathRelativeToProject(File); switch (CurrentExtension) { case eLocalSpreadsheeet.CSV: Import_CSV(File, UpdateMode); break; } ParseTerms(true); UnityEditor.EditorUtility.SetDirty(target); AssetDatabase.SaveAssets(); } } catch (System.Exception ex) { LocalizationEditor.ShowError("Unable to import file"); Debug.LogError(ex.Message); } }
TermData OnGUI_SecondaryTerm(bool OnOpen) { string Key = mLocalize.mTermSecondary; if (string.IsNullOrEmpty(Key)) { string ss; mLocalize.GetFinalTerms(out ss, out Key); } if (OnOpen) { mNewKeyName = Key; } if (OnGUI_SelectKey(ref Key, string.IsNullOrEmpty(mLocalize.mTermSecondary))) { mProp_mTermSecondary.stringValue = Key; } return(LocalizationEditor.OnGUI_Keys_Languages(Key, mLocalize, false)); }
void OnGUI_PrimaryTerm(bool OnOpen) { string Key = mLocalize.mTerm; if (string.IsNullOrEmpty(Key)) { string SecondaryTerm; mLocalize.GetFinalTerms(out Key, out SecondaryTerm); } if (OnOpen) { mNewKeyName = Key; } if (OnGUI_SelectKey(ref Key, string.IsNullOrEmpty(mLocalize.mTerm))) { mProp_mTerm.stringValue = Key; } LocalizationEditor.OnGUI_Keys_Languages(Key, mLocalize, true); }
public static void ReplaceTermsInCurrentScene() { Localize[] Locals = (Localize[])Resources.FindObjectsOfTypeAll(typeof(Localize)); if (Locals == null) { return; } bool changed = false; for (int i = 0, imax = Locals.Length; i < imax; ++i) { Localize localize = Locals[i]; if (localize == null || localize.gameObject == null || !GUITools.ObjectExistInScene(localize.gameObject)) { continue; } string NewTerm; if (TermReplacements.TryGetValue(localize.Term, out NewTerm)) { localize.mTerm = NewTerm; changed = true; } if (TermReplacements.TryGetValue(localize.SecondaryTerm, out NewTerm)) { localize.mTermSecondary = NewTerm; changed = true; } if (changed) { LocalizationEditor.Editor_MarkSceneDirty(); } } }
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); }
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); }