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($"========================================"); Debug.Log($"[TowerPopulator] DIAGNOSING TOWER SYSTEM"); Debug.Log($"========================================"); string[] prefabGuids = AssetDatabase.FindAssets("t:Tower", new[] { TOWER_PREFAB_PATH }); Debug.Log($"Tower Prefabs in Assets/Prefabs/Tower/:"); if (prefabGuids.Length == 0) { Debug.Log($"✗ No tower prefabs found!"); } else { foreach (string guid in prefabGuids) { string assetPath = AssetDatabase.GUIDToAssetPath(guid); GameObject prefab = AssetDatabase.LoadAssetAtPath(assetPath); TowerDataComponent tower = prefab?.GetComponent(); string towerStatus = tower != null && tower.towerData != null ? "✓" : "✗"; string towerDataName = tower?.towerData?.name ?? "MISSING"; Debug.Log($" {towerStatus} {prefab.name} - TowerDataComponent: {tower != null}, TowerData: {towerDataName}"); } } string[] towerDataGuids = AssetDatabase.FindAssets("t:TowerData", new[] { TOWER_DATA_PATH }); Debug.Log($"TowerData assets in Assets/Data/ScriptableObjects/:"); if (towerDataGuids.Length == 0) { Debug.Log($"⚠ No TowerData assets found - Run 'Tools > Data > Import All CSV' first!"); } else { foreach (string guid in towerDataGuids) { string assetPath = AssetDatabase.GUIDToAssetPath(guid); TowerData data = AssetDatabase.LoadAssetAtPath(assetPath); string prefabStatus = data?.prefab != null ? "✓" : "✗"; Debug.Log($" {prefabStatus} {data.name} - Prefab: {data?.prefab?.name ?? "MISSING"}, BuildingName: {data?.buildingName}"); } } BuildingManager buildingManager = GameObject.FindObjectOfType(); Debug.Log($"BuildingManager in Scene:"); if (buildingManager == null) { Debug.Log($"✗ BuildingManager not found in scene!"); } else { Debug.Log($"✓ BuildingManager found: {buildingManager.gameObject.name}"); Debug.Log($" Available Buildings: {buildingManager.availableBuildings.Count}"); foreach (var building in buildingManager.availableBuildings) { string status = building?.prefab != null ? "✓" : "✗"; string isTower = building is TowerData ? "[Tower]" : "yellow>[Building]"; Debug.Log($" {status} {isTower} {building?.name ?? "MISSING"} - {building?.buildingName}"); } } Debug.Log($"========================================"); Debug.Log($"[TowerPopulator] DIAGNOSIS COMPLETE"); Debug.Log($"========================================"); } } }