private void EditItem(object obj) { TreeViewItem item = idItems[(int)obj]; ItemEditorWindow itemEditorWindow = ItemEditorWindow.OpenEdit(item.displayName); itemEditorWindow.titleContent = new GUIContent("Edit Item"); string oldKey = item.displayName; itemEditorWindow.onFinished = (newKey, values) => { if (newKey == oldKey || !LocalizationEditorWindow.Current.DataTable.ContainsKey(newKey)) { itemEditorWindow.Close(); LocalizationEditorWindow.Current.EditItem(oldKey, newKey, values); item.displayName = newKey; (item as LanguageTreeViewItem).values = values; } else if (EditorUtility.DisplayDialog("Warning", $"已经包含名为[{newKey}]的Key,是否替换?", "Yes", "No")) { itemEditorWindow.Close(); LocalizationEditorWindow.Current.EditItem(oldKey, newKey, values); Reload(); LocalizationEditorWindow.Current.Focus(); } }; }
private void Paste(object obj) { TreeViewItem item = obj as TreeViewItem; ItemEditorWindow itemEditorWindow = ItemEditorWindow.OpenEdit(item.displayName); itemEditorWindow.titleContent = new GUIContent("Add Item"); itemEditorWindow.onFinished = (key, values) => { if (string.IsNullOrEmpty(key)) { EditorUtility.DisplayDialog("Warning", "key不能为空", "OK"); LocalizationEditorWindow.Current.Focus(); return; } if (!LocalizationEditorWindow.Current.DataTable.ContainsKey(key)) { LocalizationEditorWindow.Current.AddItem(key, values); LocalizationEditorWindow.Current.treeView.Reload(); } else if (EditorUtility.DisplayDialog("Warning", $"已经包含名为[{key}]的Key,是否替换?", "Yes", "No")) { LocalizationEditorWindow.Current.AddItem(key, values); LocalizationEditorWindow.Current.treeView.Reload(); LocalizationEditorWindow.Current.Focus(); } }; }