| | |
| | | private bool includeSubfolders = true;
|
| | | private bool compareByContent = true;
|
| | | private bool compareByName = false;
|
| | | private int minFileSize = 10;
|
| | | private int minFileSize = 100;
|
| | |
|
| | | private Dictionary<string, List<string>> duplicateGroups = new Dictionary<string, List<string>>();
|
| | | private int totalFilesScanned = 0;
|
| | |
| | | private bool isProcessing = false;
|
| | | private float progress = 0f;
|
| | | private string progressInfo = "";
|
| | |
|
| | | private string filterString = "";
|
| | | private bool enableFilter = false;
|
| | |
|
| | | [MenuItem("工具/资源管理/资源查重工具")]
|
| | | public static void ShowWindow()
|
| | |
| | | }
|
| | |
|
| | | EditorGUILayout.Space();
|
| | |
|
| | | // 搜索结果过滤功能
|
| | | EditorGUILayout.BeginVertical();
|
| | | enableFilter = EditorGUILayout.Toggle("启用结果过滤", enableFilter, GUILayout.Width(120));
|
| | | EditorGUILayout.Space();
|
| | | filterString = EditorGUILayout.TextField("过滤字符串", filterString);
|
| | | EditorGUILayout.EndVertical();
|
| | |
|
| | | if (duplicateGroups.Count > 0)
|
| | | {
|
| | |
| | | includeSubfolders = EditorGUILayout.Toggle("包含子文件夹", includeSubfolders);
|
| | | compareByContent = EditorGUILayout.Toggle("按内容比较", compareByContent);
|
| | | compareByName = EditorGUILayout.Toggle("按名称比较", compareByName);
|
| | | minFileSize = EditorGUILayout.IntField("最小文件大小 (KB)", minFileSize);
|
| | | minFileSize = EditorGUILayout.IntField("最小文件大小 (B)", minFileSize);
|
| | |
|
| | | EditorGUILayout.Space();
|
| | | EditorGUILayout.LabelField("处理选项:");
|
| | |
| | | private void DrawResults()
|
| | | {
|
| | | EditorGUI.indentLevel++;
|
| | | |
| | |
|
| | | EditorGUILayout.BeginHorizontal();
|
| | | showFullPath = EditorGUILayout.Toggle("显示完整路径", showFullPath);
|
| | | |
| | |
|
| | | GUILayout.FlexibleSpace();
|
| | | |
| | |
|
| | | if (GUILayout.Button("全选", GUILayout.Width(60)))
|
| | | {
|
| | | SelectAll(true);
|
| | | }
|
| | | |
| | |
|
| | | if (GUILayout.Button("全不选", GUILayout.Width(60)))
|
| | | {
|
| | | SelectAll(false);
|
| | | }
|
| | | |
| | |
|
| | | if (GUILayout.Button("智能选择", GUILayout.Width(80)))
|
| | | {
|
| | | SmartSelect();
|
| | | }
|
| | | |
| | |
|
| | | EditorGUILayout.EndHorizontal();
|
| | | |
| | |
|
| | | EditorGUILayout.Space();
|
| | | |
| | |
|
| | | int groupIndex = 0;
|
| | | foreach (var group in duplicateGroups)
|
| | | {
|
| | | // 过滤逻辑:只显示包含过滤字符串的组
|
| | | if (enableFilter && !group.Value.Any(f => Path.GetFileName(f).IndexOf(filterString, StringComparison.OrdinalIgnoreCase) >= 0))
|
| | | continue;
|
| | |
|
| | | if (group.Value.Count <= 1) continue;
|
| | | |
| | |
|
| | | groupIndex++;
|
| | | EditorGUILayout.BeginVertical(GUI.skin.box);
|
| | | |
| | |
|
| | | string groupTitle = $"组 {groupIndex}: {group.Value.Count} 个文件";
|
| | | if (group.Value.Count > 0)
|
| | | {
|
| | | string fileName = Path.GetFileName(group.Value[0]);
|
| | | groupTitle += $" - {fileName}";
|
| | | }
|
| | | |
| | |
|
| | | EditorGUILayout.LabelField(groupTitle, EditorStyles.boldLabel);
|
| | | |
| | |
|
| | | foreach (string filePath in group.Value)
|
| | | {
|
| | | EditorGUILayout.BeginHorizontal();
|
| | | |
| | |
|
| | | bool isSelected = false;
|
| | | if (selectedForRemoval.ContainsKey(filePath))
|
| | | {
|
| | | isSelected = selectedForRemoval[filePath];
|
| | | }
|
| | | |
| | |
|
| | | bool newSelected = EditorGUILayout.Toggle(isSelected, GUILayout.Width(20));
|
| | | if (newSelected != isSelected)
|
| | | {
|
| | | selectedForRemoval[filePath] = newSelected;
|
| | | }
|
| | | |
| | |
|
| | | string displayPath = showFullPath ? filePath : Path.GetFileName(filePath);
|
| | | |
| | |
|
| | | FileInfo fileInfo = new FileInfo(Path.Combine(Application.dataPath, "..", filePath));
|
| | | string fileDetails = $"{displayPath} - {fileInfo.Length / 1024} KB";
|
| | | |
| | |
|
| | | if (fileInfo.Exists)
|
| | | {
|
| | | fileDetails += $" - {fileInfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")}";
|
| | | }
|
| | | |
| | |
|
| | | EditorGUILayout.LabelField(fileDetails);
|
| | | |
| | |
|
| | | if (GUILayout.Button("选择", GUILayout.Width(60)))
|
| | | {
|
| | | Selection.activeObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(filePath);
|
| | | }
|
| | | |
| | |
|
| | | EditorGUILayout.EndHorizontal();
|
| | | }
|
| | | |
| | |
|
| | | EditorGUILayout.EndVertical();
|
| | | EditorGUILayout.Space();
|
| | | }
|
| | | |
| | |
|
| | | EditorGUI.indentLevel--;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | // 检查文件大小
|
| | | FileInfo fileInfo = new FileInfo(fullPath);
|
| | | if (!fileInfo.Exists || fileInfo.Length < minFileSize * 1024) continue;
|
| | | if (!fileInfo.Exists || fileInfo.Length < minFileSize) continue;
|
| | |
|
| | | string key = "";
|
| | |
|
| | |
| | |
|
| | | // 更新引用关系,将引用从filePath重定向到keepFile
|
| | | UpdateReferences(filePath, keepFile);
|
| | | |
| | | // ... existing code ...
|
| | |
|
| | | // 创建备份和删除文件的代码
|
| | | }
|