106 lines
6.0 KiB
C#
106 lines
6.0 KiB
C#
// WL-816n — 던전(아레나 복사본) 바닥·풀 실측 프로브. 에디트 모드 전용.
|
|
public static class WL816n_Probe
|
|
{
|
|
public static void Run()
|
|
{
|
|
var sb = new System.Text.StringBuilder();
|
|
var sc = UnityEditor.SceneManagement.EditorSceneManager.OpenScene(
|
|
"Assets/WL/Island/Scenes/WL_Dungeon01.unity", UnityEditor.SceneManagement.OpenSceneMode.Single);
|
|
sb.AppendLine("=== WL_Dungeon01 === roots=" + sc.rootCount);
|
|
foreach (var r in sc.GetRootGameObjects())
|
|
sb.AppendLine(" ROOT " + r.name + " active=" + r.activeSelf);
|
|
|
|
// Terrain
|
|
var ts = UnityEngine.Object.FindObjectsByType<UnityEngine.Terrain>(
|
|
UnityEngine.FindObjectsInactive.Include, UnityEngine.FindObjectsSortMode.None);
|
|
sb.AppendLine("Terrain count=" + ts.Length);
|
|
foreach (var t in ts)
|
|
{
|
|
var td = t.terrainData;
|
|
sb.AppendLine(" TERRAIN " + t.name + " mat=" + (t.materialTemplate ? t.materialTemplate.name + "/" + t.materialTemplate.shader.name : "null")
|
|
+ " size=" + (td != null ? td.size.ToString() : "?") + " pos=" + t.transform.position);
|
|
if (td != null)
|
|
{
|
|
for (int i = 0; i < td.terrainLayers.Length; i++)
|
|
{
|
|
var L = td.terrainLayers[i];
|
|
if (L == null) { sb.AppendLine(" layer" + i + " null"); continue; }
|
|
sb.AppendLine(" layer" + i + " " + L.name + " tex=" + (L.diffuseTexture ? L.diffuseTexture.name : "-")
|
|
+ " remapMin=" + L.diffuseRemapMin + " remapMax=" + L.diffuseRemapMax + " tile=" + L.tileSize
|
|
+ " path=" + UnityEditor.AssetDatabase.GetAssetPath(L));
|
|
if (L.diffuseTexture != null) sb.AppendLine(" texAvg=" + Avg(L.diffuseTexture as UnityEngine.Texture2D));
|
|
}
|
|
sb.AppendLine(" detailPrototypes=" + td.detailPrototypes.Length + " detailRes=" + td.detailResolution);
|
|
for (int i = 0; i < td.detailPrototypes.Length; i++)
|
|
{
|
|
var d = td.detailPrototypes[i];
|
|
sb.AppendLine(" det" + i + " mesh=" + (d.prototype ? d.prototype.name : "-") + " tex=" + (d.prototypeTexture ? d.prototypeTexture.name : "-")
|
|
+ " healthy=" + Hex(d.healthyColor) + " dry=" + Hex(d.dryColor) + " usePrototypeMesh=" + d.usePrototypeMesh + " render=" + d.renderMode
|
|
+ " density=" + d.density + " minW=" + d.minWidth + " maxW=" + d.maxWidth);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 바닥·풀 후보 렌더러
|
|
sb.AppendLine("--- renderers with ground/grass-ish materials ---");
|
|
var rs = UnityEngine.Object.FindObjectsByType<UnityEngine.Renderer>(
|
|
UnityEngine.FindObjectsInactive.Include, UnityEngine.FindObjectsSortMode.None);
|
|
var seen = new System.Collections.Generic.HashSet<string>();
|
|
int nR = 0;
|
|
foreach (var r in rs)
|
|
{
|
|
foreach (var m in r.sharedMaterials)
|
|
{
|
|
if (m == null) continue;
|
|
var n = m.name.ToLower();
|
|
if (n.Contains("grass") || n.Contains("ground") || n.Contains("terrain") || n.Contains("floor") || n.Contains("dirt") || n.Contains("land"))
|
|
{
|
|
var key = m.name;
|
|
if (seen.Add(key))
|
|
sb.AppendLine(" MAT " + m.name + " sh=" + m.shader.name + " path=" + UnityEditor.AssetDatabase.GetAssetPath(m) + " ex=" + r.name);
|
|
}
|
|
}
|
|
nR++;
|
|
}
|
|
sb.AppendLine(" renderers=" + nR);
|
|
|
|
// 조명
|
|
sb.AppendLine("--- lighting ---");
|
|
sb.AppendLine(" ambientMode=" + UnityEngine.RenderSettings.ambientMode
|
|
+ " light=" + Hex(UnityEngine.RenderSettings.ambientLight)
|
|
+ " sky=" + Hex(UnityEngine.RenderSettings.ambientSkyColor)
|
|
+ " eq=" + Hex(UnityEngine.RenderSettings.ambientEquatorColor)
|
|
+ " gr=" + Hex(UnityEngine.RenderSettings.ambientGroundColor)
|
|
+ " int=" + UnityEngine.RenderSettings.ambientIntensity
|
|
+ " skybox=" + (UnityEngine.RenderSettings.skybox ? UnityEngine.RenderSettings.skybox.name : "null")
|
|
+ " fog=" + UnityEngine.RenderSettings.fog);
|
|
foreach (var l in UnityEngine.Object.FindObjectsByType<UnityEngine.Light>(UnityEngine.FindObjectsInactive.Include, UnityEngine.FindObjectsSortMode.None))
|
|
sb.AppendLine(" LIGHT " + l.name + " type=" + l.type + " col=" + Hex(l.color) + " int=" + l.intensity + " rot=" + l.transform.eulerAngles + " active=" + l.gameObject.activeInHierarchy);
|
|
|
|
// Volume
|
|
foreach (var v in UnityEngine.Object.FindObjectsByType<UnityEngine.Rendering.Volume>(UnityEngine.FindObjectsInactive.Include, UnityEngine.FindObjectsSortMode.None))
|
|
sb.AppendLine(" VOLUME " + v.name + " global=" + v.isGlobal + " w=" + v.weight + " prio=" + v.priority + " profile=" + (v.sharedProfile ? v.sharedProfile.name : "null") + " active=" + v.gameObject.activeInHierarchy);
|
|
|
|
System.IO.File.WriteAllText("AgentScripts/WL816n_PROBE.txt", sb.ToString());
|
|
UnityEngine.Debug.Log("[816n] probe written\n" + sb.ToString());
|
|
}
|
|
|
|
static string Hex(UnityEngine.Color c)
|
|
{
|
|
return "#" + UnityEngine.ColorUtility.ToHtmlStringRGB(c) + "(" + c.r.ToString("F3") + "," + c.g.ToString("F3") + "," + c.b.ToString("F3") + ")";
|
|
}
|
|
|
|
static string Avg(UnityEngine.Texture2D t)
|
|
{
|
|
if (t == null) return "-";
|
|
var p = UnityEditor.AssetDatabase.GetAssetPath(t);
|
|
var imp = UnityEditor.AssetImporter.GetAtPath(p) as UnityEditor.TextureImporter;
|
|
bool rw = imp != null && imp.isReadable;
|
|
if (!rw) return "(notReadable)";
|
|
var px = t.GetPixels32();
|
|
long r = 0, g = 0, b = 0;
|
|
for (int i = 0; i < px.Length; i++) { r += px[i].r; g += px[i].g; b += px[i].b; }
|
|
return string.Format("#{0:X2}{1:X2}{2:X2} n={3}", r / px.Length, g / px.Length, b / px.Length, px.Length);
|
|
}
|
|
}
|