From 6285d7a3248a1ecb8bc72303b53383281d5ba2c2 Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Fri, 12 Jun 2026 00:01:59 +0100 Subject: group assets by source file to prevent double-counting sizes --- .../dev.zue.vrcog/Editor/VRCog/FileStatTree.cs | 52 +++++++++++++++++----- 1 file changed, 41 insertions(+), 11 deletions(-) (limited to 'Packages') diff --git a/Packages/dev.zue.vrcog/Editor/VRCog/FileStatTree.cs b/Packages/dev.zue.vrcog/Editor/VRCog/FileStatTree.cs index 6c39c2c..3929de5 100644 --- a/Packages/dev.zue.vrcog/Editor/VRCog/FileStatTree.cs +++ b/Packages/dev.zue.vrcog/Editor/VRCog/FileStatTree.cs @@ -16,9 +16,9 @@ public class FileStatTree : EditorWindow struct AssetSizeInfo { - public Object asset; + public List assets; public long size; - public string type; + public string path; } [MenuItem("Tools/VRCog/File Stat Tree")] @@ -39,11 +39,33 @@ public class FileStatTree : EditorWindow scrollPos = EditorGUILayout.BeginScrollView(scrollPos); foreach (var info in assetList) { - if (info.asset == null) continue; - EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); - EditorGUILayout.ObjectField(info.asset, info.asset.GetType(), false); + EditorGUILayout.BeginVertical(EditorStyles.helpBox); + EditorGUILayout.BeginHorizontal(); + if (info.assets.Count == 1) + { + Object a = info.assets[0]; + if (a != null) + EditorGUILayout.ObjectField(a, a.GetType(), false); + else + EditorGUILayout.LabelField(Path.GetFileName(info.path)); + } + else + { + EditorGUILayout.LabelField($"{Path.GetFileName(info.path)} ({info.assets.Count} assets)"); + } GUILayout.Label(FormatSize(info.size), GUILayout.Width(80)); EditorGUILayout.EndHorizontal(); + if (info.assets.Count > 1) + { + EditorGUI.indentLevel++; + foreach (Object a in info.assets) + { + if (a == null) continue; + EditorGUILayout.ObjectField(a, a.GetType(), false); + } + EditorGUI.indentLevel--; + } + EditorGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); } @@ -99,17 +121,25 @@ public class FileStatTree : EditorWindow } } + // Group assets by source file so each file's size is counted only once + var byPath = new Dictionary>(); foreach (var asset in foundAssets) { string path = AssetDatabase.GetAssetPath(asset); - if (!string.IsNullOrEmpty(path)) + if (string.IsNullOrEmpty(path)) continue; + if (!byPath.TryGetValue(path, out List list)) { - FileInfo fi = new FileInfo(path); - if (fi.Exists) - { - assetList.Add(new AssetSizeInfo { asset = asset, size = fi.Length, type = asset.GetType().Name }); - } + list = new List(); + byPath[path] = list; } + list.Add(asset); + } + + foreach (var kvp in byPath) + { + FileInfo fi = new FileInfo(kvp.Key); + if (fi.Exists) + assetList.Add(new AssetSizeInfo { assets = kvp.Value, size = fi.Length, path = kvp.Key }); } // Sort by size descending -- cgit v1.2.3