aboutsummaryrefslogtreecommitdiff
path: root/Assets
diff options
context:
space:
mode:
Diffstat (limited to 'Assets')
-rw-r--r--Assets/Editor/VRCog/FileStatTree.cs107
-rw-r--r--Assets/Editor/VRCog/PoiyomiFinder.cs81
2 files changed, 0 insertions, 188 deletions
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<AssetSizeInfo> assetList = new List<AssetSizeInfo>();
- 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<FileStatTree>("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<Object> foundAssets = new HashSet<Object>();
- Renderer[] renderers = targetObject.GetComponentsInChildren<Renderer>(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<MeshFilter>();
- 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<GameObject> results = new List<GameObject>();
- private Vector2 scrollPos;
-
- [MenuItem("Tools/VRCog/Poiyomi Finder")]
- public static void ShowWindow()
- {
- GetWindow<PoiyomiFinder>("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<Renderer>(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