using UnityEditor;
using UnityEngine;

public static class GeoBoundsDebug
{
    [MenuItem("Tools/Geo/Print Selected Mesh Bounds")]
    public static void PrintSelectedMeshBounds()
    {
        foreach (var go in Selection.gameObjects)
        {
            var mf = go.GetComponent<MeshFilter>();
            if (mf == null || mf.sharedMesh == null)
            {
                Debug.Log($"{go.name}: no MeshFilter/mesh");
                continue;
            }

            var mesh = mf.sharedMesh;
            var b = mesh.bounds;

            // Mesh bounds are in local mesh space
            var centerWorld = go.transform.TransformPoint(b.center);

            // Approximate size in world space (ignores rotation, good enough for diagnosis)
            var lossy = go.transform.lossyScale;
            var sizeWorld = new Vector3(
                Mathf.Abs(b.size.x * lossy.x),
                Mathf.Abs(b.size.y * lossy.y),
                Mathf.Abs(b.size.z * lossy.z)
            );

            Debug.Log($"{go.name}: worldCenter={centerWorld}, worldSize={sizeWorld}");
        }
    }
}
