81 lines
4.0 KiB
C#
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.FindFirstObjectByType<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>");
|
|
}
|
|
}
|
|
}
|