62 lines
3.4 KiB
C#
62 lines
3.4 KiB
C#
// ToonTerrain 이 터레인 스플랫(_Control) 을 실제로 쓰는지 최종 판정.
|
|
// R=마젠타 · G=시안 으로 동시에 바꾼 뒤 아레나 카메라(각도 43.61°)와 탑다운 둘 다 찍는다.
|
|
public static class WL814q_Probe3
|
|
{
|
|
const string ScenePath = "Assets/WL/Look/Arena/Scenes/WL_ArenaProto.unity";
|
|
const string NewMat = "Assets/WL/Look/Arena/Materials/WL_ArenaTerrain.mat";
|
|
|
|
static UnityEngine.Texture2D Shot(UnityEngine.Camera cam, int w, int h)
|
|
{
|
|
var rt = new UnityEngine.RenderTexture(w, h, 24, UnityEngine.RenderTextureFormat.ARGB32,
|
|
UnityEngine.RenderTextureReadWrite.sRGB);
|
|
rt.Create(); cam.targetTexture = rt; cam.Render();
|
|
var old = UnityEngine.RenderTexture.active; UnityEngine.RenderTexture.active = rt;
|
|
var tex = new UnityEngine.Texture2D(w, h, UnityEngine.TextureFormat.RGB24, false);
|
|
tex.ReadPixels(new UnityEngine.Rect(0, 0, w, h), 0, 0); tex.Apply();
|
|
UnityEngine.RenderTexture.active = old; cam.targetTexture = null;
|
|
rt.Release(); UnityEngine.Object.DestroyImmediate(rt);
|
|
return tex;
|
|
}
|
|
|
|
static string Px(UnityEngine.Texture2D t, int x, int y)
|
|
{
|
|
var c = t.GetPixel(x, y);
|
|
return string.Format("({0},{1},{2})", (int)(c.r * 255), (int)(c.g * 255), (int)(c.b * 255));
|
|
}
|
|
|
|
public static string Run()
|
|
{
|
|
var sb = new System.Text.StringBuilder();
|
|
var m = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEngine.Material>(NewMat);
|
|
var red = m.GetColor("_RedHighlight"); var grn = m.GetColor("_GreenHighlight");
|
|
m.SetColor("_RedHighlight", new UnityEngine.Color(1f, 0f, 1f, 0f)); // 마젠타
|
|
m.SetColor("_GreenHighlight", new UnityEngine.Color(0f, 1f, 1f, 0f)); // 시안
|
|
UnityEditor.EditorUtility.SetDirty(m); UnityEditor.AssetDatabase.SaveAssets();
|
|
|
|
UnityEditor.SceneManagement.EditorSceneManager.OpenScene(ScenePath,
|
|
UnityEditor.SceneManagement.OpenSceneMode.Single);
|
|
UnityEngine.Camera cam = null;
|
|
foreach (var c in UnityEngine.Object.FindObjectsByType<UnityEngine.Camera>(UnityEngine.FindObjectsSortMode.None))
|
|
if (c.gameObject.name == "Main Camera") cam = c;
|
|
for (int i = 0; i < 3; i++) UnityEngine.Object.DestroyImmediate(Shot(cam, 64, 64));
|
|
|
|
var a = Shot(cam, 540, 960); // 아레나 도트A 각도 · 화면 전부가 반경 5 m 안쪽(스플랫상 흙 1.0)
|
|
sb.AppendLine("arena-cam(ortho3.4) 지면: " + Px(a, 120, 620) + " " + Px(a, 430, 200) + " " + Px(a, 270, 350));
|
|
UnityEngine.Object.DestroyImmediate(a);
|
|
|
|
cam.orthographic = true; cam.orthographicSize = 22f;
|
|
cam.transform.position = new UnityEngine.Vector3(0f, 30f, 0f);
|
|
cam.transform.rotation = UnityEngine.Quaternion.Euler(90f, 0f, 0f);
|
|
var b = Shot(cam, 540, 960);
|
|
// (270,480)=중앙(캐릭터가 있으니 살짝 비켜서 샘플) · 안쪽 r≈4 m · 바깥 r≈20 m
|
|
sb.AppendLine("top-down 중앙옆(r~2m): " + Px(b, 300, 480) + " r~5m: " + Px(b, 340, 560)
|
|
+ " r~20m: " + Px(b, 60, 100) + " " + Px(b, 500, 880));
|
|
UnityEngine.Object.DestroyImmediate(b);
|
|
|
|
m.SetColor("_RedHighlight", red); m.SetColor("_GreenHighlight", grn);
|
|
UnityEditor.EditorUtility.SetDirty(m); UnityEditor.AssetDatabase.SaveAssets();
|
|
sb.AppendLine("restored R=" + m.GetColor("_RedHighlight") + " G=" + m.GetColor("_GreenHighlight"));
|
|
return sb.ToString();
|
|
}
|
|
}
|