// WL-816h — ⓓ 데모 씬과 나란히 (에디트 모드 렌더 · §9 데모 Play 안 함) using UnityEngine; using UnityEngine.Rendering.Universal; using UnityEditor; public static class WL816h_Demo { const string Dir = "Screenshots_WL/WL816h/"; const int W = 1080, H = 1920; public static void Run() { var sb = new System.Text.StringBuilder(); UnityEditor.SceneManagement.EditorSceneManager.OpenScene( "Assets/LowPolyFantasyArena/Scenes/LowPolyArena_Demo.unity", UnityEditor.SceneManagement.OpenSceneMode.Single); // 수평선이 보이는 화각 — 우리 섬 캡처(b_after_horizon)와 같은 fov·피치 var go = new GameObject("~WL816hDemoCam"); go.hideFlags = HideFlags.DontSave; var c = go.AddComponent(); c.orthographic = false; c.fieldOfView = 55f; c.nearClipPlane = 0.3f; c.farClipPlane = 2000f; c.clearFlags = CameraClearFlags.Skybox; c.cullingMask = ~0; c.depth = -100f; go.transform.position = new Vector3(-14f, 8f, -14f); go.transform.rotation = Quaternion.Euler(4f, 45f, 0f); go.AddComponent(); sb.AppendLine("데모 = " + Shot(c, Dir + "x_demo_horizon.png")); Object.DestroyImmediate(go); Pair(Dir + "x_demo_horizon.png", Dir + "b_after_horizon.png", Dir + "d_demo_vs_island.png"); sb.AppendLine("나란히 = " + Dir + "d_demo_vs_island.png (좌 데모 / 우 우리 섬 · 같은 화각)"); System.IO.File.WriteAllText("AgentScripts/WL816h_DEMO.txt", sb.ToString()); Debug.Log("[816h demo]\n" + sb); // 다음 작업을 위해 InGame 으로 돌려 둔다(데모 씬 저장 0) UnityEditor.SceneManagement.EditorSceneManager.OpenScene( "Assets/Scenes/InGame.unity", UnityEditor.SceneManagement.OpenSceneMode.Single); } static string Shot(Camera cam, string path) { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path)); var rt = new RenderTexture(W, H, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB); rt.antiAliasing = 1; rt.Create(); var pA = RenderTexture.active; cam.targetTexture = rt; cam.Render(); RenderTexture.active = rt; var tex = new Texture2D(W, H, TextureFormat.RGB24, false); tex.ReadPixels(new Rect(0, 0, W, H), 0, 0); tex.Apply(); RenderTexture.active = pA; cam.targetTexture = null; System.IO.File.WriteAllBytes(path, tex.EncodeToPNG()); var px = tex.GetPixels32(); long r = 0, g = 0, b = 0; for (int i = 0; i < px.Length; i += 7) { r += px[i].r; g += px[i].g; b += px[i].b; } int n = (px.Length + 6) / 7; Object.DestroyImmediate(tex); rt.Release(); Object.DestroyImmediate(rt); return "#" + ((int)(r / n)).ToString("X2") + ((int)(g / n)).ToString("X2") + ((int)(b / n)).ToString("X2") + " → " + path; } static void Pair(string left, string right, string outPath) { var a = Load(left); var b = Load(right); if (a == null || b == null) { Debug.Log("[816h] 나란히 실패 " + left + " / " + right); return; } int w = a.width + b.width, h = Mathf.Max(a.height, b.height); var o = new Texture2D(w, h, TextureFormat.RGB24, false); var fill = new Color32[w * h]; for (int i = 0; i < fill.Length; i++) fill[i] = new Color32(24, 24, 28, 255); o.SetPixels32(fill); o.SetPixels32(0, 0, a.width, a.height, a.GetPixels32()); o.SetPixels32(a.width, 0, b.width, b.height, b.GetPixels32()); o.Apply(); System.IO.File.WriteAllBytes(outPath, o.EncodeToPNG()); Object.DestroyImmediate(o); Object.DestroyImmediate(a); Object.DestroyImmediate(b); } static Texture2D Load(string p) { if (!System.IO.File.Exists(p)) return null; var t = new Texture2D(2, 2, TextureFormat.RGB24, false); t.LoadImage(System.IO.File.ReadAllBytes(p)); return t; } }