public void UpdateUnusedAssets() { var all = new HashSet <string>(_forward.Keys); var withBacklinks = new HashSet <string>(Backward.Where(kv => kv.Value.Lookup.Count > 0).Select(kv => kv.Key)); all.ExceptWith(withBacklinks); all.RemoveWhere(SearchUtils.IsFileIgrnoredBySettings); var unusedAssets = all; var scenes = unusedAssets.Where(s => AssetDatabase.GetMainAssetTypeAtPath(s).IsAssignableFromInverse(typeof(SceneAsset))).ToArray(); unusedAssets.ExceptWith(scenes); var files = unusedAssets; UnusedFiles = new Dictionary <string, long>(); foreach (var file in files) { UnusedFiles[file] = CommonUtils.Size(file); } UnusedScenes = new Dictionary <string, long>(); foreach (var scene in scenes) { UnusedScenes[scene] = CommonUtils.Size(scene); } // UpdateFoldersWithQty(); foreach (var folder in Folders) { var unusedFilesQty = UnusedFiles.Count(p => p.Key.StartsWith(folder)); var unusedScenesQty = UnusedScenes.Count(p => p.Key.StartsWith(folder)); long size = 0; size = UnusedFiles.Where((p => p.Key.StartsWith(folder))).Sum(p => p.Value); size += UnusedScenes.Where(p => p.Key.StartsWith(folder)).Sum(p => p.Value); FoldersWithQty.TryGetValue(folder, out var folderWithQty); if (folderWithQty == null) { FoldersWithQty.Add(folder, new UnusedQty(unusedFilesQty, unusedScenesQty, size)); } else { folderWithQty.UnusedFilesQty = unusedFilesQty; folderWithQty.UnusedScenesQty = unusedScenesQty; folderWithQty.UnusedSize = size; } } }