59 lines
3.9 KiB
C#
59 lines
3.9 KiB
C#
// WL_GroundProbe.cs — 지면 색 진단 (에디트 모드 · 읽기 전용)
|
|
// unity command run_script --file AgentScripts/WL_GroundProbe.cs --entry WL_GroundProbe.Under --args '["Assets/Res_Addr/Map/WL_Nature.prefab", 115.0, 10.0]'
|
|
// 지정 XZ 를 바운즈에 포함하는 지형 렌더러(MT/CPT 모듈)와 그 머티리얼(셰이더 · 색 · 스무스니스 · 메탈릭 · 스페큘러 하이라이트 키워드)을 나열한다.
|
|
using System.Linq;
|
|
using System.Text;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
public static class WL_GroundProbe
|
|
{
|
|
public static object Under(string prefabPath, float x, float z)
|
|
{
|
|
var root = PrefabUtility.LoadPrefabContents(prefabPath);
|
|
var sb = new StringBuilder();
|
|
try
|
|
{
|
|
var rs = root.GetComponentsInChildren<MeshRenderer>(true)
|
|
.Where(r => !r.name.StartsWith("WL_") && !r.name.StartsWith("Water"))
|
|
.Where(r => { var b = r.bounds; return x >= b.min.x && x <= b.max.x && z >= b.min.z && z <= b.max.z && b.size.x * b.size.z > 100f; })
|
|
.OrderByDescending(r => r.bounds.size.x * r.bounds.size.z)
|
|
.Take(6)
|
|
.ToArray();
|
|
sb.AppendLine("terrain renderers containing (" + x + ", " + z + "): " + rs.Length);
|
|
foreach (var r in rs)
|
|
{
|
|
var b = r.bounds;
|
|
sb.AppendLine(" - " + r.name + " active=" + r.gameObject.activeInHierarchy + " bounds y " + b.min.y.ToString("F2") + "~" + b.max.y.ToString("F2")
|
|
+ " x " + b.min.x.ToString("F0") + "~" + b.max.x.ToString("F0") + " z " + b.min.z.ToString("F0") + "~" + b.max.z.ToString("F0"));
|
|
foreach (var m in r.sharedMaterials)
|
|
{
|
|
if (m == null) { sb.AppendLine(" mat=NULL"); continue; }
|
|
string col = m.HasProperty("_BaseColor") ? m.GetColor("_BaseColor").ToString("F2") : "-";
|
|
string sm = m.HasProperty("_Smoothness") ? m.GetFloat("_Smoothness").ToString("F2") : "-";
|
|
string me = m.HasProperty("_Metallic") ? m.GetFloat("_Metallic").ToString("F2") : "-";
|
|
string spec = m.HasProperty("_SpecularHighlights") ? m.GetFloat("_SpecularHighlights").ToString("F0") : "-";
|
|
string env = m.HasProperty("_EnvironmentReflections") ? m.GetFloat("_EnvironmentReflections").ToString("F0") : "-";
|
|
string tex = m.HasProperty("_BaseMap") && m.GetTexture("_BaseMap") != null ? m.GetTexture("_BaseMap").name : "none";
|
|
sb.AppendLine(" mat=" + m.name + " shader=" + m.shader.name + " base=" + col + " tex=" + tex + " smooth=" + sm + " metal=" + me + " specHL=" + spec + " envRefl=" + env
|
|
+ " kw=[" + string.Join(",", m.shaderKeywords) + "] path=" + AssetDatabase.GetAssetPath(m));
|
|
}
|
|
}
|
|
var lights = root.GetComponentsInChildren<Light>(true);
|
|
sb.AppendLine("lights=" + lights.Length);
|
|
foreach (var l in lights) sb.AppendLine(" - " + l.name + " type=" + l.type + " int=" + l.intensity.ToString("F2") + " col=" + l.color.ToString("F2") + " euler=" + l.transform.eulerAngles.ToString("F0") + " active=" + l.gameObject.activeInHierarchy);
|
|
var md = root.GetComponent<MapData>();
|
|
if (md != null)
|
|
{
|
|
var t = md.GetType();
|
|
foreach (var f in new[] { "ambientMode", "ambientSky", "ambientEquator", "ambientGround", "ambientIntensity", "reflectionIntensity", "fogEnabled", "fogColor", "fogStart", "fogEnd" })
|
|
{
|
|
var fi = t.GetField(f); if (fi != null) sb.AppendLine(" MapData." + f + " = " + fi.GetValue(md));
|
|
}
|
|
}
|
|
}
|
|
finally { PrefabUtility.UnloadPrefabContents(root); }
|
|
return sb.ToString();
|
|
}
|
|
}
|