Files
grass-cutters/Assets/Editor/ModelAudit.cs
NiemandKG d1c3761e58 Grass Cutters Together: the project as of moon-sweepers f3666f0
A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and
Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date.
Images, audio, models and binaries go through Git LFS (.gitattributes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 18:44:40 +06:00

37 lines
1.4 KiB
C#

using System.Text;
using UnityEditor;
using UnityEngine;
namespace GrassCutter.EditorTools
{
/// <summary>Logs root/child rotations and world-space bounds of every imported model (to catch axis problems).</summary>
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<GameObject>(path);
var go = (GameObject)Object.Instantiate(prefab);
var rs = go.GetComponentsInChildren<Renderer>();
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);
}
}
}