2026-06-01 씬전환시 무기 사라지는 현상 수정
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
//
|
||||
// _slots는 데이터가 아니라 생성한 화면 오브젝트 캐시일 뿐 (재사용 풀).
|
||||
// ============================================================================
|
||||
public class WeaponInventory : MonoBehaviour
|
||||
public class WeaponInventory : MonoBehaviour, ISceneInitializable
|
||||
{
|
||||
[SerializeField] private PlayerWeaponInventory _wInvenSource; // 비워두면 런타임에 자동 탐색
|
||||
[SerializeField] private Transform _slotRoot; // 슬롯이 생성될 부모
|
||||
@@ -33,6 +33,7 @@ private void Start()
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_wInvenSource != null)
|
||||
@@ -40,6 +41,17 @@ private void OnDestroy()
|
||||
}
|
||||
|
||||
|
||||
public void OnSceneLoaded()
|
||||
{
|
||||
if (_wInvenSource == null)
|
||||
_wInvenSource = FindFirstObjectByType<PlayerWeaponInventory>();
|
||||
|
||||
if (_wInvenSource != null)
|
||||
_wInvenSource.OnInventoryChanged += Refresh;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
// 인벤토리 상태를 화면에 반영. 슬롯 개수를 무기 수에 맞추고 내용/하이라이트 갱신.
|
||||
private void Refresh()
|
||||
{
|
||||
@@ -61,4 +73,5 @@ private void Refresh()
|
||||
_slots[i].SetSelected(i == _wInvenSource.CurrentIndex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user