Improve FBX/prefab import setup, CharacterSpawner, and add M3 inspect/rebuild helpers. Co-authored-by: Cursor <cursoragent@cursor.com>
48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using System.Text;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
public static class InspectMaleExplorerMesh
|
|
{
|
|
public static string Execute()
|
|
{
|
|
const string fbx = "Assets/Bundles/Characters/MaleExplorer/MaleExplorer.fbx";
|
|
const string prefabPath = "Assets/Bundles/Characters/MaleExplorer/MaleExplorer.prefab";
|
|
var sb = new StringBuilder();
|
|
|
|
foreach (var obj in AssetDatabase.LoadAllAssetsAtPath(fbx))
|
|
{
|
|
if (obj is Mesh mesh)
|
|
{
|
|
sb.AppendLine(
|
|
$"assetMesh={mesh.name} verts={mesh.vertexCount} bounds={mesh.bounds} " +
|
|
$"tris={mesh.triangles.Length / 3}");
|
|
}
|
|
}
|
|
|
|
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
|
|
var go = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
|
go.transform.position = Vector3.zero;
|
|
go.transform.localScale = Vector3.one;
|
|
foreach (var mf in go.GetComponentsInChildren<MeshFilter>(true))
|
|
{
|
|
var m = mf.sharedMesh;
|
|
if (m == null) continue;
|
|
sb.AppendLine($"filter={mf.name} localScale={mf.transform.lossyScale} meshBounds={m.bounds} worldBounds={mf.GetComponent<Renderer>().bounds}");
|
|
// sample a few verts
|
|
var vs = m.vertices;
|
|
var min = vs[0];
|
|
var max = vs[0];
|
|
for (int i = 1; i < vs.Length; i++)
|
|
{
|
|
min = Vector3.Min(min, vs[i]);
|
|
max = Vector3.Max(max, vs[i]);
|
|
}
|
|
sb.AppendLine($"vertMin={min} vertMax={max} size={max - min}");
|
|
}
|
|
|
|
Object.DestroyImmediate(go);
|
|
return sb.ToString();
|
|
}
|
|
}
|