// WL796_Shot.cs — Play 중 실제 게임 렌더(Screen 해상도 그대로)를 PNG 로 저장한다. // unity command run_script --file AgentScripts/WL796_Shot.cs --entry WL796_Shot.Grab --args '["wl796_A_1080x1920"]' // unity command run_script --file AgentScripts/WL796_Shot.cs --entry WL796_Shot.Result // capture_game_view --source screen 은 에디터 창 비율로 나와 세로 화면 검증에 쓸 수 없어 직접 캡처한다. using System.Collections; using System.IO; using UnityEngine; public static class WL796_Shot { const string OutDir = "Screenshots_WL/hud2"; static string s_result = "(not run)"; class Host : MonoBehaviour { public string fileName; public IEnumerator Co() { yield return new WaitForEndOfFrame(); var tex = ScreenCapture.CaptureScreenshotAsTexture(); Directory.CreateDirectory(OutDir); var path = Path.Combine(OutDir, fileName + ".png"); File.WriteAllBytes(path, tex.EncodeToPNG()); s_result = "saved " + path + " " + tex.width + "x" + tex.height; Object.Destroy(tex); Object.Destroy(gameObject); } } public static object Grab(string fileName) { if (!Application.isPlaying) return "not playing"; s_result = "(pending)"; var host = new GameObject("__wl796shot").AddComponent(); host.fileName = fileName; host.StartCoroutine(host.Co()); return "capturing -> " + fileName + ".png (Result 로 확인)"; } public static object Result() { return s_result; } }