diff --git a/Assets/Scripts/Skills/Runtime/PlayerSkillInventory.cs b/Assets/Scripts/Skills/Runtime/PlayerSkillInventory.cs index 609bf93..8eafd97 100644 --- a/Assets/Scripts/Skills/Runtime/PlayerSkillInventory.cs +++ b/Assets/Scripts/Skills/Runtime/PlayerSkillInventory.cs @@ -45,11 +45,55 @@ namespace EerieVillage.Skills void Awake() { + // PD 지시 2026-05-14 — 게임 재실행 시 이전 Play 잔존 spawn (투사체·박스·Range) 강제 cleanup. + // HideFlags.DontSave 정합 외 DontDestroyOnLoad·Scene 영구 저장·메모리 잔존 경로 방어. + CleanupStalePooledSpawns(); + Stats = new PlayerStats(); PlayerStats.Current = Stats; _health = GetComponent(); } + // PD 지시 2026-05-14 — 잔존 풀링 GameObject 강제 cleanup + // 대상: Projectile 및 파생 (HomingProjectile·PiercingProjectile) + 박스 시각화 GameObject + static readonly System.Collections.Generic.HashSet StaleSpawnNames = + new System.Collections.Generic.HashSet + { + "Hitbox_Debug", + "ProjectileHitbox_Debug", + "LaserHitbox_Debug", + "MeleeHitbox_Debug", + "Range_Debug", + }; + + void CleanupStalePooledSpawns() + { + int removed = 0; + // (1) Projectile 및 파생 component GameObject — root 단위 destroy + var projs = Resources.FindObjectsOfTypeAll(); + foreach (var p in projs) + { + if (p == null || p.gameObject == null) continue; + if (!p.gameObject.scene.IsValid()) continue; // prefab asset 제외 + Destroy(p.gameObject); + removed++; + } + // (2) 박스 시각화 — name 기반 (자체 부착 컴포넌트 부재 케이스) + var allGOs = Resources.FindObjectsOfTypeAll(); + foreach (var go in allGOs) + { + if (go == null) continue; + if (!go.scene.IsValid()) continue; + if (StaleSpawnNames.Contains(go.name)) + { + Destroy(go); + removed++; + } + } + if (removed > 0) + Debug.Log("[PlayerSkillInventory] CleanupStalePooledSpawns removed=" + removed); + } + // PD 지시 2026-05-13 — Start 시점에 기본 습득 스킬 자동 장착 (Resources 로드 완료 후·Awake 영역 아님) void Start() {