Files
Northbound/Assets/Scripts/Editor/TowerPopulator.cs
dal4segno 4200288fae 건설 인터랙션 관련 버그 수정 및 건설 데이터 구조 개선
건설 인터랙션 시 움직이지 못하는 문제 수정
2개로 분리되어 있던 타워 데이터를 하나로 통합
 - 대신 타워가 아닌 건물도 공격력 등을 정의할 수 있음
2026-02-01 16:09:57 +09:00

81 lines
4.0 KiB
C#

using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using Northbound;
using Northbound.Data;
namespace Northbound.Editor
{
public class TowerPopulator
{
private const string TOWER_PREFAB_PATH = "Assets/Prefabs/Tower";
private const string TOWER_DATA_PATH = "Assets/Data/ScriptableObjects";
[MenuItem("Northbound/Diagnose Tower System")]
public static void DiagnoseTowerSystem()
{
Debug.Log($"<color=cyan>========================================</color>");
Debug.Log($"<color=cyan>[TowerPopulator] DIAGNOSING TOWER SYSTEM</color>");
Debug.Log($"<color=cyan>========================================</color>");
string[] prefabGuids = AssetDatabase.FindAssets("t:Tower", new[] { TOWER_PREFAB_PATH });
Debug.Log($"<color=cyan>Tower Prefabs in Assets/Prefabs/Tower/:</color>");
if (prefabGuids.Length == 0)
{
Debug.Log($"<color=red>✗ No tower prefabs found!</color>");
}
else
{
foreach (string guid in prefabGuids)
{
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
Building building = prefab?.GetComponent<Building>();
string towerStatus = building != null && building.buildingData != null ? "<color=green>✓</color>" : "<color=red>✗</color>";
string towerDataName = building?.buildingData?.name ?? "MISSING";
Debug.Log($" {towerStatus} {prefab.name} - Building: {building != null}, TowerData: {towerDataName}");
}
}
string[] towerDataGuids = AssetDatabase.FindAssets("t:TowerData", new[] { TOWER_DATA_PATH });
Debug.Log($"<color=cyan>TowerData assets in Assets/Data/ScriptableObjects/:</color>");
if (towerDataGuids.Length == 0)
{
Debug.Log($"<color=yellow>⚠ No TowerData assets found - Run 'Tools > Data > Import All CSV' first!</color>");
}
else
{
foreach (string guid in towerDataGuids)
{
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
TowerData data = AssetDatabase.LoadAssetAtPath<TowerData>(assetPath);
string prefabStatus = data?.prefab != null ? "<color=green>✓</color>" : "<color=red>✗</color>";
Debug.Log($" {prefabStatus} {data.name} - Prefab: {data?.prefab?.name ?? "MISSING"}, BuildingName: {data?.buildingName}");
}
}
BuildingManager buildingManager = GameObject.FindObjectOfType<BuildingManager>();
Debug.Log($"<color=cyan>BuildingManager in Scene:</color>");
if (buildingManager == null)
{
Debug.Log($"<color=red>✗ BuildingManager not found in scene!</color>");
}
else
{
Debug.Log($"<color=green>✓ BuildingManager found: {buildingManager.gameObject.name}</color>");
Debug.Log($"<color=cyan> Available Buildings: {buildingManager.availableBuildings.Count}</color>");
foreach (var building in buildingManager.availableBuildings)
{
string status = building?.prefab != null ? "<color=green>✓</color>" : "<color=red>✗</color>";
string isTower = building is TowerData ? "<color=green>[Tower]</color>" : "<color>yellow>[Building]</color>";
Debug.Log($" {status} {isTower} {building?.name ?? "MISSING"} - {building?.buildingName}");
}
}
Debug.Log($"<color=cyan>========================================</color>");
Debug.Log($"<color=cyan>[TowerPopulator] DIAGNOSIS COMPLETE</color>");
Debug.Log($"<color=cyan>========================================</color>");
}
}
}