Unity 6.5 업그레이드와 신규 프로토타입 기반 구축
This commit is contained in:
@@ -5,24 +5,21 @@ using Northbound.Data;
|
||||
namespace Northbound
|
||||
{
|
||||
/// <summary>
|
||||
/// 업그레이드 데이터를 자동으로 로드하고 관리하는 싱글톤
|
||||
/// Resources 폴더에서 모든 UpgradeData를 자동으로 로드
|
||||
/// 씬에서 직접 참조한 UpgradeData ScriptableObject를 조회하는 싱글톤
|
||||
/// </summary>
|
||||
public class UpgradeDatabase : MonoBehaviour
|
||||
{
|
||||
private static UpgradeDatabase _instance;
|
||||
public static UpgradeDatabase Instance => _instance;
|
||||
|
||||
// Resources에서 자동 로드된 데이터
|
||||
private List<UpgradeData> _upgradeDataList = new List<UpgradeData>();
|
||||
[Header("ScriptableObject Data")]
|
||||
[Tooltip("업그레이드 데이터의 단일 원본 목록입니다. Resources 자동 검색 대신 SO를 직접 등록합니다.")]
|
||||
[SerializeField] private List<UpgradeData> _upgradeDataList = new List<UpgradeData>();
|
||||
|
||||
// 조회용 딕셔너리
|
||||
private Dictionary<int, UpgradeData> _upgradeById = new Dictionary<int, UpgradeData>();
|
||||
private Dictionary<string, List<UpgradeData>> _upgradesByCategory = new Dictionary<string, List<UpgradeData>>();
|
||||
|
||||
// Resources 경로
|
||||
private const string UPGRADE_RESOURCES_PATH = "Data/ScriptableObjects/Upgrade";
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (_instance != null && _instance != this)
|
||||
@@ -32,23 +29,9 @@ namespace Northbound
|
||||
}
|
||||
|
||||
_instance = this;
|
||||
LoadUpgradeData();
|
||||
BuildLookupTables();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resources에서 모든 UpgradeData 자동 로드
|
||||
/// </summary>
|
||||
private void LoadUpgradeData()
|
||||
{
|
||||
_upgradeDataList.Clear();
|
||||
|
||||
var upgrades = Resources.LoadAll<UpgradeData>(UPGRADE_RESOURCES_PATH);
|
||||
_upgradeDataList.AddRange(upgrades);
|
||||
|
||||
Debug.Log($"[UpgradeDatabase] {_upgradeDataList.Count}개의 업그레이드 데이터를 로드했습니다.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 조회용 테이블 구축
|
||||
/// </summary>
|
||||
@@ -66,6 +49,11 @@ namespace Northbound
|
||||
{
|
||||
_upgradeById[upgrade.id] = upgrade;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"[UpgradeDatabase] 중복 업그레이드 ID: {upgrade.id}", upgrade);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 카테고리로 조회
|
||||
string category = upgrade.upgradeCategory;
|
||||
@@ -82,7 +70,6 @@ namespace Northbound
|
||||
/// </summary>
|
||||
public void ReloadData()
|
||||
{
|
||||
LoadUpgradeData();
|
||||
BuildLookupTables();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user