aboutsummaryrefslogtreecommitdiff
path: root/Packages/dev.zue.vrcog
diff options
context:
space:
mode:
Diffstat (limited to 'Packages/dev.zue.vrcog')
-rw-r--r--Packages/dev.zue.vrcog/Editor/VRCog/FileStatTree.cs248
-rw-r--r--Packages/dev.zue.vrcog/Editor/VRCog/PoiyomiFinder.cs130
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<AssetSizeInfo> assetList = new List<AssetSizeInfo>();
- private Vector2 scrollPos;
-
- [System.Serializable]
- struct AssetSizeInfo
- {
- public List<Object> assets;
- public long size;
- public string path;
- }
-
- [MenuItem("Tools/VRCog/File Stat Tree")]
- public static void ShowWindow() => GetWindow<FileStatTree>("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<AssetSizeInfo> assetList = new List<AssetSizeInfo>();
+ private Vector2 scrollPos;
- if (GUILayout.Button("Analyze Hierarchy Assets"))
+ [System.Serializable]
+ struct AssetSizeInfo
{
- AnalyzeAssets();
+ public List<Object> assets;
+ public long size;
+ public string path;
}
- EditorGUILayout.Space();
+ [MenuItem("Tools/VRCog/File Stat Tree")]
+ public static void ShowWindow() => GetWindow<FileStatTree>("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<Object> foundAssets = new HashSet<Object>();
- Renderer[] renderers = targetObject.GetComponentsInChildren<Renderer>(true);
+ HashSet<Object> foundAssets = new HashSet<Object>();
+ Renderer[] renderers = targetObject.GetComponentsInChildren<Renderer>(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<MeshFilter>();
+ 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<string, List<Object>>();
+ 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<MeshFilter>();
- 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<Object> list))
+ {
+ list = new List<Object>();
+ byPath[path] = list;
+ }
+ list.Add(asset);
}
- }
- // Group assets by source file so each file's size is counted only once
- var byPath = new Dictionary<string, List<Object>>();
- foreach (var asset in foundAssets)
- {
- string path = AssetDatabase.GetAssetPath(asset);
- if (string.IsNullOrEmpty(path)) continue;
- if (!byPath.TryGetValue(path, out List<Object> list))
+ foreach (var kvp in byPath)
{
- list = new List<Object>();
- 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<MatchInfo> results = new List<MatchInfo>();
- 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<MatchInfo> results = new List<MatchInfo>();
+ private Vector2 scrollPos;
- [MenuItem("Tools/VRCog/Poiyomi Finder")]
- public static void ShowWindow()
- {
- GetWindow<PoiyomiFinder>("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<PoiyomiFinder>("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<GameObject> seen = new HashSet<GameObject>();
- Renderer[] renderers = targetObject.GetComponentsInChildren<Renderer>(true);
+ EditorGUILayout.EndScrollView();
+ }
+ }
- foreach (Renderer ren in renderers)
+ private void FindMaterials()
{
- foreach (Material mat in ren.sharedMaterials)
+ results.Clear();
+ if (targetObject == null) return;
+
+ HashSet<GameObject> seen = new HashSet<GameObject>();
+ Renderer[] renderers = targetObject.GetComponentsInChildren<Renderer>(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