using System.Text; using UnityEditor; using UnityEngine; namespace GrassCutter.EditorTools { /// Logs root/child rotations and world-space bounds of every imported model (to catch axis problems). public static class ModelAudit { [MenuItem("GrassCutter/Audit Models")] public static void Run() { var sb = new StringBuilder("[Audit]\n"); foreach (var guid in AssetDatabase.FindAssets("t:Model", new[] { "Assets/Art/Models" })) { var path = AssetDatabase.GUIDToAssetPath(guid); var prefab = AssetDatabase.LoadAssetAtPath(path); var go = (GameObject)Object.Instantiate(prefab); var rs = go.GetComponentsInChildren(); Bounds b = rs.Length > 0 ? rs[0].bounds : new Bounds(); foreach (var r in rs) b.Encapsulate(r.bounds); sb.Append($"{prefab.name}: rootRot={go.transform.localEulerAngles} size={b.size:F2} center={b.center:F2}\n"); foreach (Transform c in go.transform) sb.Append($" - {c.name} pos={c.localPosition:F2} rot={c.localEulerAngles:F0} scale={c.localScale:F2}\n"); Object.DestroyImmediate(go); } Debug.Log(sb.ToString()); } public static void BatchRun() { Run(); EditorApplication.Exit(0); } } }