From 52e38afb56320e6ecceb58705b4bf92ca76ba4f4 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 11 Jun 2026 23:29:41 +0100 Subject: move to proper dir --- Assets/Editor/VRCog/FileStatTree.cs | 107 ----------------------------------- Assets/Editor/VRCog/PoiyomiFinder.cs | 81 -------------------------- 2 files changed, 188 deletions(-) delete mode 100644 Assets/Editor/VRCog/FileStatTree.cs delete mode 100644 Assets/Editor/VRCog/PoiyomiFinder.cs (limited to 'Assets') diff --git a/Assets/Editor/VRCog/FileStatTree.cs b/Assets/Editor/VRCog/FileStatTree.cs deleted file mode 100644 index 3e1fe81..0000000 --- a/Assets/Editor/VRCog/FileStatTree.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Editor window for auditing assets referenced by a hierarchy root. -// -// It collects unique materials, textures used by those materials, and meshes found under the selected GameObject, then displays them sorted by on-disk file size so large contributors are easy to spot. - -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -public class FileStatTree : EditorWindow -{ - private GameObject targetObject; - private List assetList = new List(); - private Vector2 scrollPos; - - struct AssetSizeInfo - { - public Object asset; - public long size; - public string type; - } - - [MenuItem("Tools/VRCog/File Stat Tree")] - public static void ShowWindow() => GetWindow("File Stat Tree"); - - private void OnGUI() - { - GUILayout.Label("Sort Hierarchy Assets by Size", EditorStyles.boldLabel); - targetObject = (GameObject)EditorGUILayout.ObjectField("Target Root", targetObject, typeof(GameObject), true); - - if (GUILayout.Button("Analyze Hierarchy Assets")) - { - AnalyzeAssets(); - } - - EditorGUILayout.Space(); - - scrollPos = EditorGUILayout.BeginScrollView(scrollPos); - foreach (var info in assetList) - { - EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); - EditorGUILayout.ObjectField(info.asset, info.asset.GetType(), false); - GUILayout.Label(FormatSize(info.size), GUILayout.Width(80)); - EditorGUILayout.EndHorizontal(); - } - EditorGUILayout.EndScrollView(); - } - - private void AnalyzeAssets() - { - assetList.Clear(); - if (targetObject == null) return; - - HashSet foundAssets = new HashSet(); - Renderer[] renderers = targetObject.GetComponentsInChildren(true); - - foreach (var ren in renderers) - { - foreach (var mat in ren.sharedMaterials) - { - 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++) - { - if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv) - { - Texture tex = mat.GetTexture(ShaderUtil.GetPropertyName(shader, i)); - if (tex != null) foundAssets.Add(tex); - } - } - } - - // Track Mesh - MeshFilter mf = ren.GetComponent(); - if (mf != null && mf.sharedMesh != null) foundAssets.Add(mf.sharedMesh); - } - - foreach (var asset in foundAssets) - { - string path = AssetDatabase.GetAssetPath(asset); - if (!string.IsNullOrEmpty(path)) - { - FileInfo fi = new FileInfo(path); - if (fi.Exists) - { - assetList.Add(new AssetSizeInfo { asset = asset, size = fi.Length, type = asset.GetType().Name }); - } - } - } - - // 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"; - } -} \ No newline at end of file diff --git a/Assets/Editor/VRCog/PoiyomiFinder.cs b/Assets/Editor/VRCog/PoiyomiFinder.cs deleted file mode 100644 index 6a65445..0000000 --- a/Assets/Editor/VRCog/PoiyomiFinder.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Editor window for finding objects that use Poiyomi shaders in a hierarchy. -// -// It scans renderers under the selected root GameObject, lists each matching object once, and provides a quick Select action to jump directly to results for material cleanup. - -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; - -public class PoiyomiFinder : EditorWindow -{ - private GameObject targetObject; - 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 Poiyomi Shaders", EditorStyles.boldLabel); - - targetObject = (GameObject)EditorGUILayout.ObjectField("Target Root", targetObject, typeof(GameObject), true); - - if (GUILayout.Button("Find Poiyomi Materials")) - { - FindMaterials(); - } - - EditorGUILayout.Space(); - - if (results.Count > 0) - { - GUILayout.Label($"Found {results.Count} objects:", EditorStyles.helpBox); - scrollPos = EditorGUILayout.BeginScrollView(scrollPos); - - foreach (GameObject obj in results) - { - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.ObjectField(obj, typeof(GameObject), true); - if (GUILayout.Button("Select", GUILayout.Width(60))) - { - Selection.activeGameObject = obj; - } - EditorGUILayout.EndHorizontal(); - } - - EditorGUILayout.EndScrollView(); - } - } - - private void FindMaterials() - { - results.Clear(); - if (targetObject == null) return; - - // Get all renderers in children - Renderer[] renderers = targetObject.GetComponentsInChildren(true); - - foreach (Renderer ren in renderers) - { - foreach (Material mat in ren.sharedMaterials) - { - if (mat != null && mat.shader != null) - { - // Check if the shader name contains "poiyomi" (case-insensitive) - if (mat.shader.name.ToLower().Contains("poiyomi")) - { - if (!results.Contains(ren.gameObject)) - { - results.Add(ren.gameObject); - } - break; // Move to next renderer once found - } - } - } - } - } -} \ No newline at end of file -- cgit v1.2.3