From 39dc9c9efe1b0bceb70dd03c56f4031b67d41486 Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Fri, 12 Jun 2026 00:14:21 +0100 Subject: formatting! --- .../dev.zue.vrcog/Editor/VRCog/FileStatTree.cs | 248 ++++++++++----------- .../dev.zue.vrcog/Editor/VRCog/PoiyomiFinder.cs | 130 +++++------ 2 files changed, 189 insertions(+), 189 deletions(-) diff --git a/Packages/dev.zue.vrcog/Editor/VRCog/FileStatTree.cs b/Packages/dev.zue.vrcog/Editor/VRCog/FileStatTree.cs index 89bb1e5..522ab7f 100644 --- a/Packages/dev.zue.vrcog/Editor/VRCog/FileStatTree.cs +++ b/Packages/dev.zue.vrcog/Editor/VRCog/FileStatTree.cs @@ -11,165 +11,165 @@ using System.Linq; namespace Zue.VRCog.Editor { -public class FileStatTree : EditorWindow -{ - private GameObject targetObject; - [SerializeField] private List assetList = new List(); - private Vector2 scrollPos; - - [System.Serializable] - struct AssetSizeInfo - { - public List assets; - public long size; - public string path; - } - - [MenuItem("Tools/VRCog/File Stat Tree")] - public static void ShowWindow() => GetWindow("File Stat Tree"); - - private void OnGUI() + public class FileStatTree : EditorWindow { - GUILayout.Label("Sort Hierarchy Assets by Size", EditorStyles.boldLabel); - targetObject = (GameObject)EditorGUILayout.ObjectField("Target Root", targetObject, typeof(GameObject), true); + private GameObject targetObject; + [SerializeField] private List assetList = new List(); + private Vector2 scrollPos; - if (GUILayout.Button("Analyze Hierarchy Assets")) + [System.Serializable] + struct AssetSizeInfo { - AnalyzeAssets(); + public List assets; + public long size; + public string path; } - EditorGUILayout.Space(); + [MenuItem("Tools/VRCog/File Stat Tree")] + public static void ShowWindow() => GetWindow("File Stat Tree"); - if (assetList.Count > 0) + private void OnGUI() { - EditorGUILayout.HelpBox( - "Sizes shown are on-disk file sizes and do not reflect runtime memory usage. " + - "A compressed texture may be small on disk but large in VRAM once decompressed, and vice versa. " + - "For accurate runtime figures, use the Memory Profiler package.", - MessageType.Info); - } + GUILayout.Label("Sort Hierarchy Assets by Size", EditorStyles.boldLabel); + targetObject = (GameObject)EditorGUILayout.ObjectField("Target Root", targetObject, typeof(GameObject), true); - scrollPos = EditorGUILayout.BeginScrollView(scrollPos); - foreach (var info in assetList) - { - EditorGUILayout.BeginVertical(EditorStyles.helpBox); - EditorGUILayout.BeginHorizontal(); - if (info.assets.Count == 1) + if (GUILayout.Button("Analyze Hierarchy Assets")) { - Object a = info.assets[0]; - if (a != null) - { - EditorGUILayout.ObjectField(a, a.GetType(), false); - GUILayout.Label(a.GetType().Name, GUILayout.Width(90)); - } - else - EditorGUILayout.LabelField(Path.GetFileName(info.path)); + AnalyzeAssets(); } - else + + EditorGUILayout.Space(); + + if (assetList.Count > 0) { - EditorGUILayout.LabelField($"{Path.GetFileName(info.path)} ({info.assets.Count} assets)"); + EditorGUILayout.HelpBox( + "Sizes shown are on-disk file sizes and do not reflect runtime memory usage. " + + "A compressed texture may be small on disk but large in VRAM once decompressed, and vice versa. " + + "For accurate runtime figures, use the Memory Profiler package.", + MessageType.Info); } - GUILayout.Label(FormatSize(info.size), GUILayout.Width(80)); - EditorGUILayout.EndHorizontal(); - if (info.assets.Count > 1) + + scrollPos = EditorGUILayout.BeginScrollView(scrollPos); + foreach (var info in assetList) { - EditorGUI.indentLevel++; - foreach (Object a in info.assets) + EditorGUILayout.BeginVertical(EditorStyles.helpBox); + EditorGUILayout.BeginHorizontal(); + if (info.assets.Count == 1) { - if (a == null) continue; - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.ObjectField(a, a.GetType(), false); - GUILayout.Label(a.GetType().Name, GUILayout.Width(90)); - EditorGUILayout.EndHorizontal(); + Object a = info.assets[0]; + if (a != null) + { + EditorGUILayout.ObjectField(a, a.GetType(), false); + GUILayout.Label(a.GetType().Name, GUILayout.Width(90)); + } + 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.BeginHorizontal(); + EditorGUILayout.ObjectField(a, a.GetType(), false); + GUILayout.Label(a.GetType().Name, GUILayout.Width(90)); + EditorGUILayout.EndHorizontal(); + } + EditorGUI.indentLevel--; } - EditorGUI.indentLevel--; + EditorGUILayout.EndVertical(); } - EditorGUILayout.EndVertical(); + EditorGUILayout.EndScrollView(); } - EditorGUILayout.EndScrollView(); - } - private void AnalyzeAssets() - { - assetList.Clear(); - if (targetObject == null) return; + private void AnalyzeAssets() + { + assetList.Clear(); + if (targetObject == null) return; - HashSet foundAssets = new HashSet(); - Renderer[] renderers = targetObject.GetComponentsInChildren(true); + HashSet foundAssets = new HashSet(); + Renderer[] renderers = targetObject.GetComponentsInChildren(true); - foreach (var ren in renderers) - { - foreach (var mat in ren.sharedMaterials) + foreach (var ren in renderers) { - if (mat == null) continue; - - // Track the Material - foundAssets.Add(mat); - - // Track Textures within that material - Shader shader = mat.shader; - int propertyCount = ShaderUtil.GetPropertyCount(shader); - for (int i = 0; i < propertyCount; i++) + foreach (var mat in ren.sharedMaterials) { - if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv) + if (mat == null) continue; + + // Track the Material + foundAssets.Add(mat); + + // Track Textures within that material + Shader shader = mat.shader; + int propertyCount = ShaderUtil.GetPropertyCount(shader); + for (int i = 0; i < propertyCount; i++) { - Texture tex = mat.GetTexture(ShaderUtil.GetPropertyName(shader, i)); - if (tex != null) foundAssets.Add(tex); + if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv) + { + Texture tex = mat.GetTexture(ShaderUtil.GetPropertyName(shader, i)); + if (tex != null) foundAssets.Add(tex); + } } } + + // Track Mesh + switch (ren) + { + case SkinnedMeshRenderer smr: + if (smr.sharedMesh != null) foundAssets.Add(smr.sharedMesh); + break; + case ParticleSystemRenderer psr when psr.renderMode == ParticleSystemRenderMode.Mesh: + Mesh[] particleMeshes = new Mesh[psr.meshCount]; + psr.GetMeshes(particleMeshes); + foreach (Mesh m in particleMeshes) + { + if (m != null) foundAssets.Add(m); + } + break; + default: + MeshFilter mf = ren.GetComponent(); + if (mf != null && mf.sharedMesh != null) foundAssets.Add(mf.sharedMesh); + break; + } } - - // Track Mesh - switch (ren) + + // Group assets by source file so each file's size is counted only once + var byPath = new Dictionary>(); + foreach (var asset in foundAssets) { - case SkinnedMeshRenderer smr: - if (smr.sharedMesh != null) foundAssets.Add(smr.sharedMesh); - break; - case ParticleSystemRenderer psr when psr.renderMode == ParticleSystemRenderMode.Mesh: - Mesh[] particleMeshes = new Mesh[psr.meshCount]; - psr.GetMeshes(particleMeshes); - foreach (Mesh m in particleMeshes) - { - if (m != null) foundAssets.Add(m); - } - break; - default: - MeshFilter mf = ren.GetComponent(); - if (mf != null && mf.sharedMesh != null) foundAssets.Add(mf.sharedMesh); - break; + string path = AssetDatabase.GetAssetPath(asset); + if (string.IsNullOrEmpty(path)) continue; + if (!byPath.TryGetValue(path, out List list)) + { + list = new List(); + byPath[path] = list; + } + list.Add(asset); } - } - // 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)) continue; - if (!byPath.TryGetValue(path, out List list)) + foreach (var kvp in byPath) { - list = new List(); - byPath[path] = list; + FileInfo fi = new FileInfo(kvp.Key); + if (fi.Exists) + assetList.Add(new AssetSizeInfo { assets = kvp.Value, size = fi.Length, path = kvp.Key }); } - list.Add(asset); + + // Sort by size descending + assetList = assetList.OrderByDescending(asf => asf.size).ToList(); } - foreach (var kvp in byPath) + private string FormatSize(long bytes) { - FileInfo fi = new FileInfo(kvp.Key); - if (fi.Exists) - assetList.Add(new AssetSizeInfo { assets = kvp.Value, size = fi.Length, path = kvp.Key }); + if (bytes >= 1048576) return (bytes / 1048576f).ToString("F2") + " MB"; + return (bytes / 1024f).ToString("F2") + " KB"; } - - // Sort by size descending - assetList = assetList.OrderByDescending(asf => asf.size).ToList(); - } - - private string FormatSize(long bytes) - { - if (bytes >= 1048576) return (bytes / 1048576f).ToString("F2") + " MB"; - return (bytes / 1024f).ToString("F2") + " KB"; } -} } // namespace Zue.VRCog.Editor \ No newline at end of file diff --git a/Packages/dev.zue.vrcog/Editor/VRCog/PoiyomiFinder.cs b/Packages/dev.zue.vrcog/Editor/VRCog/PoiyomiFinder.cs index b6fd218..9c53eb0 100644 --- a/Packages/dev.zue.vrcog/Editor/VRCog/PoiyomiFinder.cs +++ b/Packages/dev.zue.vrcog/Editor/VRCog/PoiyomiFinder.cs @@ -11,102 +11,102 @@ using System.Linq; namespace Zue.VRCog.Editor { -public class PoiyomiFinder : EditorWindow -{ - private GameObject targetObject; - private string shaderFilter = "poiyomi"; - private List results = new List(); - private Vector2 scrollPos; - - struct MatchInfo + public class PoiyomiFinder : EditorWindow { - public GameObject gameObject; - public string matchedMaterial; - public string matchedShader; - } + private GameObject targetObject; + private string shaderFilter = "poiyomi"; + private List results = new List(); + private Vector2 scrollPos; - [MenuItem("Tools/VRCog/Poiyomi Finder")] - public static void ShowWindow() - { - GetWindow("Poiyomi Finder"); - } - - private void OnGUI() - { - GUILayout.Label("Search Hierarchy for Shaders", EditorStyles.boldLabel); - - targetObject = (GameObject)EditorGUILayout.ObjectField("Target Root", targetObject, typeof(GameObject), true); - shaderFilter = EditorGUILayout.TextField("Shader Filter", shaderFilter); - - if (GUILayout.Button("Find Materials")) + struct MatchInfo { - FindMaterials(); + public GameObject gameObject; + public string matchedMaterial; + public string matchedShader; } - EditorGUILayout.Space(); + [MenuItem("Tools/VRCog/Poiyomi Finder")] + public static void ShowWindow() + { + GetWindow("Poiyomi Finder"); + } - if (results.Count > 0) + private void OnGUI() { - EditorGUILayout.BeginHorizontal(); - GUILayout.Label($"Found {results.Count} objects:", EditorStyles.helpBox); - if (GUILayout.Button("Select All", GUILayout.Width(80))) + GUILayout.Label("Search Hierarchy for Shaders", EditorStyles.boldLabel); + + targetObject = (GameObject)EditorGUILayout.ObjectField("Target Root", targetObject, typeof(GameObject), true); + shaderFilter = EditorGUILayout.TextField("Shader Filter", shaderFilter); + + if (GUILayout.Button("Find Materials")) { - Selection.objects = results.Select(r => (Object)r.gameObject).ToArray(); + FindMaterials(); } - EditorGUILayout.EndHorizontal(); - scrollPos = EditorGUILayout.BeginScrollView(scrollPos); + EditorGUILayout.Space(); - foreach (MatchInfo info in results) + if (results.Count > 0) { - EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); - EditorGUILayout.ObjectField(info.gameObject, typeof(GameObject), true); - if (GUILayout.Button("Select", GUILayout.Width(60))) + GUILayout.Label($"Found {results.Count} objects:", EditorStyles.helpBox); + if (GUILayout.Button("Select All", GUILayout.Width(80))) { - Selection.activeGameObject = info.gameObject; - EditorGUIUtility.PingObject(info.gameObject); + Selection.objects = results.Select(r => (Object)r.gameObject).ToArray(); } EditorGUILayout.EndHorizontal(); - EditorGUILayout.LabelField($"mat: {info.matchedMaterial} · shader: {info.matchedShader}", EditorStyles.miniLabel); - EditorGUILayout.EndVertical(); - } - EditorGUILayout.EndScrollView(); - } - } + scrollPos = EditorGUILayout.BeginScrollView(scrollPos); - private void FindMaterials() - { - results.Clear(); - if (targetObject == null) return; + foreach (MatchInfo info in results) + { + EditorGUILayout.BeginVertical(EditorStyles.helpBox); + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.ObjectField(info.gameObject, typeof(GameObject), true); + if (GUILayout.Button("Select", GUILayout.Width(60))) + { + Selection.activeGameObject = info.gameObject; + EditorGUIUtility.PingObject(info.gameObject); + } + EditorGUILayout.EndHorizontal(); + EditorGUILayout.LabelField($"mat: {info.matchedMaterial} · shader: {info.matchedShader}", EditorStyles.miniLabel); + EditorGUILayout.EndVertical(); + } - HashSet seen = new HashSet(); - Renderer[] renderers = targetObject.GetComponentsInChildren(true); + EditorGUILayout.EndScrollView(); + } + } - foreach (Renderer ren in renderers) + private void FindMaterials() { - foreach (Material mat in ren.sharedMaterials) + results.Clear(); + if (targetObject == null) return; + + HashSet seen = new HashSet(); + Renderer[] renderers = targetObject.GetComponentsInChildren(true); + + foreach (Renderer ren in renderers) { - if (mat != null && mat.shader != null) + foreach (Material mat in ren.sharedMaterials) { - if (mat.shader.name.IndexOf(shaderFilter, StringComparison.OrdinalIgnoreCase) >= 0) + if (mat != null && mat.shader != null) { - if (seen.Add(ren.gameObject)) + if (mat.shader.name.IndexOf(shaderFilter, StringComparison.OrdinalIgnoreCase) >= 0) { - results.Add(new MatchInfo + if (seen.Add(ren.gameObject)) { - gameObject = ren.gameObject, - matchedMaterial = mat.name, - matchedShader = mat.shader.name - }); + results.Add(new MatchInfo + { + gameObject = ren.gameObject, + matchedMaterial = mat.name, + matchedShader = mat.shader.name + }); + } + break; } - break; } } } } } -} } // namespace Zue.VRCog.Editor \ No newline at end of file -- cgit v1.2.3