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 ---------------- Packages/.gitignore | 2 +- .../Editor/ExampleEditorScript.cs | 10 -- .../Editor/VRChatPackageTemplate.Editor.asmdef | 15 --- Packages/com.vrchat.demo-template/package.json | 13 --- .../dev.zue.vrcog/Editor/VRCog/FileStatTree.cs | 107 +++++++++++++++++++++ .../dev.zue.vrcog/Editor/VRCog/PoiyomiFinder.cs | 81 ++++++++++++++++ Packages/dev.zue.vrcog/package.json | 13 +++ 9 files changed, 202 insertions(+), 227 deletions(-) delete mode 100644 Assets/Editor/VRCog/FileStatTree.cs delete mode 100644 Assets/Editor/VRCog/PoiyomiFinder.cs delete mode 100644 Packages/com.vrchat.demo-template/Editor/ExampleEditorScript.cs delete mode 100644 Packages/com.vrchat.demo-template/Editor/VRChatPackageTemplate.Editor.asmdef delete mode 100644 Packages/com.vrchat.demo-template/package.json create mode 100644 Packages/dev.zue.vrcog/Editor/VRCog/FileStatTree.cs create mode 100644 Packages/dev.zue.vrcog/Editor/VRCog/PoiyomiFinder.cs create mode 100644 Packages/dev.zue.vrcog/package.json 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 diff --git a/Packages/.gitignore b/Packages/.gitignore index 3ed669d..d30b8f2 100644 --- a/Packages/.gitignore +++ b/Packages/.gitignore @@ -2,4 +2,4 @@ !com.vrchat.core.* # Change this to match your new package name -!com.vrchat.demo-template \ No newline at end of file +!dev.zue.vrcog \ No newline at end of file diff --git a/Packages/com.vrchat.demo-template/Editor/ExampleEditorScript.cs b/Packages/com.vrchat.demo-template/Editor/ExampleEditorScript.cs deleted file mode 100644 index b5250de..0000000 --- a/Packages/com.vrchat.demo-template/Editor/ExampleEditorScript.cs +++ /dev/null @@ -1,10 +0,0 @@ -using UnityEditor; - -public class ExampleEditorScript -{ - [MenuItem("Example Editor Script/Test")] - static void Test() - { - EditorUtility.DisplayDialog("Example Script", "Opened This Dialog", "OK"); - } -} diff --git a/Packages/com.vrchat.demo-template/Editor/VRChatPackageTemplate.Editor.asmdef b/Packages/com.vrchat.demo-template/Editor/VRChatPackageTemplate.Editor.asmdef deleted file mode 100644 index 968b1f3..0000000 --- a/Packages/com.vrchat.demo-template/Editor/VRChatPackageTemplate.Editor.asmdef +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "VRChatPackageTemplate.Editor", - "references": [], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Packages/com.vrchat.demo-template/package.json b/Packages/com.vrchat.demo-template/package.json deleted file mode 100644 index 4b90c5e..0000000 --- a/Packages/com.vrchat.demo-template/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "com.vrchat.demo-template", - "displayName": "VRChat Example Package", - "version": "0.0.7", - "unity": "2022.3", - "description": "Simple Package for testing Automation", - "vrchatVersion": "2022.1.1", - "author": { - "name": "Momo the Monster", - "email": "momodmonster@gmail.com", - "url": "https://mmmlabs.com" - } -} \ No newline at end of file diff --git a/Packages/dev.zue.vrcog/Editor/VRCog/FileStatTree.cs b/Packages/dev.zue.vrcog/Editor/VRCog/FileStatTree.cs new file mode 100644 index 0000000..3e1fe81 --- /dev/null +++ b/Packages/dev.zue.vrcog/Editor/VRCog/FileStatTree.cs @@ -0,0 +1,107 @@ +// 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/Packages/dev.zue.vrcog/Editor/VRCog/PoiyomiFinder.cs b/Packages/dev.zue.vrcog/Editor/VRCog/PoiyomiFinder.cs new file mode 100644 index 0000000..6a65445 --- /dev/null +++ b/Packages/dev.zue.vrcog/Editor/VRCog/PoiyomiFinder.cs @@ -0,0 +1,81 @@ +// 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 diff --git a/Packages/dev.zue.vrcog/package.json b/Packages/dev.zue.vrcog/package.json new file mode 100644 index 0000000..d712e30 --- /dev/null +++ b/Packages/dev.zue.vrcog/package.json @@ -0,0 +1,13 @@ +{ + "name": "dev.zue.vrcog", + "displayName": "VRCog", + "version": "0.0.1", + "unity": "2022.3", + "description": "Unity editor utilities for VRChat creators. The missing gear in your workflow.", + "vrchatVersion": "2022.1.1", + "author": { + "name": "Alex Pooley (@zuedev)", + "email": "zuedev@gmail.com", + "url": "https://zue.dev" + } +} \ No newline at end of file -- cgit v1.2.3