using System; using System.Collections.Generic; using UnityEngine; // 전투 유닛 도트 그림 — Resources/Art/Units/px_<그림 id>.png(PD 원화 시트 80종 도트화 · 2026-10-28) // 유닛 → 그림 = Data/unit_art.json(표에 없거나 그림이 없으면 null → 코드 그림 그대로) namespace VS.View { public static class UnitArt { [Serializable] class Row { public int id; public int art; } [Serializable] class Table { public Row[] units; } static Dictionary map; static readonly Dictionary cache = new Dictionary(); public static Sprite ForUnit(int unitId) { if (map == null) { map = new Dictionary(); var txt = GameApp.ReadData("unit_art"); if (txt != null) foreach (var r in JsonUtility.FromJson(txt).units) map[r.id] = r.art; } return map.TryGetValue(unitId, out var art) ? Get(art) : null; } public static Sprite Get(int art) { if (cache.TryGetValue(art, out var s)) return s; s = Resources.Load("Art/Units/px_" + art); if (s == null) { // .meta 가 Sprite 로 안 들어간 경우 — 텍스처로 읽어 점 필터 스프라이트로 var tex = Resources.Load("Art/Units/px_" + art); if (tex != null) { tex.filterMode = FilterMode.Point; s = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0f), 32); } } cache[art] = s; return s; } } }