데이터파이프라인 타워 부분 개선

This commit is contained in:
2026-02-01 11:31:50 +09:00
parent 9d870625ce
commit fe046611b0
43 changed files with 2181 additions and 45 deletions

View File

@@ -189,6 +189,13 @@ namespace Northbound
}
Debug.Log($"[BuildingPlacement] 건설 모드 {(isBuildModeActive ? "" : "")}");
Debug.Log($"[BuildingPlacement] Preview object: {(previewObject != null ? "CREATED" : "NULL")}");
if (previewObject != null)
{
Debug.Log($"[BuildingPlacement] Preview position: {previewObject.transform.position}");
Debug.Log($"[BuildingPlacement] Preview scale: {previewObject.transform.localScale}");
Debug.Log($"[BuildingPlacement] Preview active: {previewObject.activeSelf}");
}
}
/// <summary>
@@ -231,6 +238,10 @@ namespace Northbound
return;
}
Debug.Log($"<color=cyan>[BuildingPlacement] Creating preview...</color>");
Debug.Log($"<color=cyan>[BuildingPlacement] BuildingManager.availableBuildings.Count: {BuildingManager.Instance.availableBuildings.Count}</color>");
Debug.Log($"<color=cyan>[BuildingPlacement] selectedBuildingIndex: {selectedBuildingIndex}</color>");
if (selectedBuildingIndex < 0 || selectedBuildingIndex >= BuildingManager.Instance.availableBuildings.Count)
{
Debug.LogWarning($"[BuildingPlacement] 유효하지 않은 건물 인덱스: {selectedBuildingIndex}");
@@ -238,12 +249,21 @@ namespace Northbound
}
BuildingData data = BuildingManager.Instance.availableBuildings[selectedBuildingIndex];
if (data == null || data.prefab == null)
if (data == null)
{
Debug.LogWarning("[BuildingPlacement] BuildingData 또는 Prefab이 없습니다.");
Debug.LogError($"[BuildingPlacement] BuildingData is NULL at index {selectedBuildingIndex}");
return;
}
if (data.prefab == null)
{
Debug.LogError($"[BuildingPlacement] BuildingData.prefab is NULL at index {selectedBuildingIndex}. Run 'Northbound > Diagnose Tower System'");
return;
}
Debug.Log($"<color=green>[BuildingPlacement] BuildingData: {data.buildingName}, Prefab: {data.prefab.name}</color>");
Debug.Log($"<color=green>[BuildingPlacement] Prefab scale: {data.prefab.transform.localScale}</color>");
// 완성 건물 프리팹으로 프리뷰 생성 (사용자가 완성 모습을 볼 수 있도록)
previewObject = Instantiate(data.prefab);
@@ -296,11 +316,17 @@ namespace Northbound
if (previewObject == null || BuildingManager.Instance == null)
return;
if (selectedBuildingIndex < 0 || selectedBuildingIndex >= BuildingManager.Instance.availableBuildings.Count)
return;
BuildingData data = BuildingManager.Instance.availableBuildings[selectedBuildingIndex];
if (data == null || data.prefab == null)
return;
Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.ReadValue());
if (Physics.Raycast(ray, out RaycastHit hit, maxPlacementDistance, groundLayer))
{
BuildingData data = BuildingManager.Instance.availableBuildings[selectedBuildingIndex];
// Check if placement is valid
bool isValid = BuildingManager.Instance.IsValidPlacement(data, hit.point, currentRotation, out Vector3 snappedPosition);
@@ -412,13 +438,24 @@ namespace Northbound
{
if (BuildingManager.Instance == null) return;
if (selectedBuildingIndex < 0 || selectedBuildingIndex >= BuildingManager.Instance.availableBuildings.Count)
{
Debug.LogWarning($"[BuildingPlacement] Invalid building index: {selectedBuildingIndex}");
return;
}
BuildingData data = BuildingManager.Instance.availableBuildings[selectedBuildingIndex];
if (data == null || data.prefab == null)
{
Debug.LogError($"[BuildingPlacement] BuildingData or prefab is null at index {selectedBuildingIndex}. Please run 'Northbound > Populate Towers from Prefabs' and update BuildingManager.");
return;
}
Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.ReadValue());
if (!Physics.Raycast(ray, out RaycastHit hit, maxPlacementDistance, groundLayer))
{
return;
}
BuildingData data = BuildingManager.Instance.availableBuildings[selectedBuildingIndex];
// 드래그 영역 계산
Vector3 dragEndPosition = hit.point;

View File

@@ -99,6 +99,8 @@ namespace Northbound
Debug.LogWarning($"[BuildingQuickslotUI] QuickSlot{i + 1} 액션이 null입니다. Input Actions 에셋을 확인하세요.");
}
}
Debug.Log($"[BuildingQuickslotUI] {_quickslotActions.Length}개의 퀵슬롯 액션 초기화됨 (최대 8개 키 바인딩)");
}
/// <summary>
@@ -155,6 +157,10 @@ namespace Northbound
{
SelectBuilding(slotIndex);
}
else if (slotIndex >= slotButtons.Count && quickslotPanel != null && quickslotPanel.activeSelf)
{
Debug.LogWarning($"[BuildingQuickslotUI] 슬롯 {slotIndex + 1}은 존재하지 않습니다. 마우스로 클릭하여 선택하세요.");
}
}
/// <summary>
@@ -176,11 +182,10 @@ namespace Northbound
}
slotButtons.Clear();
// 건물 목록으로 슬롯 생성 (최대 maxSlots개)
// 모든 건물 슬롯 생성 (제한 없음)
var buildings = BuildingManager.Instance.availableBuildings;
int slotCount = Mathf.Min(buildings.Count, maxSlots);
for (int i = 0; i < slotCount; i++)
for (int i = 0; i < buildings.Count; i++)
{
CreateSlot(buildings[i], i);
}

View File

@@ -0,0 +1,353 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using Northbound.Data;
namespace Northbound.Editor
{
public class CSVToSOImporter : EditorWindow
{
private static Dictionary<string, IPrefabSetup> prefabSetups;
[MenuItem("Tools/Data/Import All CSV")]
public static void ImportAllCSV()
{
InitializePrefabSetups();
string dataPath = Path.Combine(Application.dataPath, "../GameData");
if (!Directory.Exists(dataPath))
{
Debug.LogError("[CSVToSOImporter] GameData folder not found!");
return;
}
string[] csvFiles = Directory.GetFiles(dataPath, "*.csv");
int successCount = 0;
int failCount = 0;
bool towerImported = false;
foreach (string csvFile in csvFiles)
{
string fileName = Path.GetFileNameWithoutExtension(csvFile);
if (ImportCSV(fileName))
{
successCount++;
if (fileName == "Tower")
towerImported = true;
}
else
{
failCount++;
}
}
Debug.Log($"<color=green>[CSVToSOImporter] Import complete: {successCount} succeeded, {failCount} failed</color>");
if (towerImported)
{
AutoConfigureBuildingManager();
}
AssetDatabase.Refresh();
}
private static void InitializePrefabSetups()
{
prefabSetups = new Dictionary<string, IPrefabSetup>
{
{ "Monster", new MonsterPrefabSetup() },
{ "Tower", new TowerPrefabSetup() }
};
}
private static bool ImportCSV(string typeName)
{
string csvPath = Path.Combine(Application.dataPath, "../GameData", $"{typeName}.csv");
if (!File.Exists(csvPath))
{
Debug.LogWarning($"[CSVToSOImporter] CSV file not found: {csvPath}");
return false;
}
if (!prefabSetups.ContainsKey(typeName))
{
Debug.LogWarning($"[CSVToSOImporter] No prefab setup found for type: {typeName}");
return false;
}
IPrefabSetup prefabSetup = prefabSetups[typeName];
string templateName = prefabSetup.GetTemplateName();
string templatePath = $"Assets/Data/Templates/{templateName}.prefab";
GameObject template = AssetDatabase.LoadAssetAtPath<GameObject>(templatePath);
if (template == null)
{
Debug.LogError($"[CSVToSOImporter] Template not found: {templatePath}");
return false;
}
string[] csvLines = File.ReadAllLines(csvPath);
if (csvLines.Length < 2)
{
Debug.LogWarning($"[CSVToSOImporter] CSV file is empty or has no data: {csvPath}");
return false;
}
string[] headers = ParseCSVLine(csvLines[0]);
int successCount = 0;
for (int i = 1; i < csvLines.Length; i++)
{
if (string.IsNullOrWhiteSpace(csvLines[i]))
continue;
string[] values = ParseCSVLine(csvLines[i]);
if (CreatePrefabFromRow(typeName, headers, values, template, prefabSetup))
{
successCount++;
}
}
Debug.Log($"[CSVToSOImporter] {typeName}: {successCount} prefabs created/updated");
// If towers were imported, auto-configure BuildingManager
// TowerData now extends BuildingData, so it can be used directly!
if (typeName == "Tower")
{
Debug.Log($"<color=cyan>[CSVToSOImporter] Tower import complete, TowerData extends BuildingData now!</color>");
}
return true;
}
private static bool CreatePrefabFromRow(string typeName, string[] headers, string[] values, GameObject template, IPrefabSetup prefabSetup)
{
string soPath = $"Assets/Data/ScriptableObjects/{typeName}";
Directory.CreateDirectory(Path.Combine(Application.dataPath, $"ScriptableObjects/{typeName}"));
int id = 0;
for (int i = 0; i < headers.Length && i < values.Length; i++)
{
if (headers[i].ToLower() == "id")
{
int.TryParse(values[i], out id);
break;
}
}
if (id == 0)
{
Debug.LogWarning($"[CSVToSOImporter] No valid ID found in row");
return false;
}
ScriptableObject data;
string soAssetPath = $"{soPath}/{typeName}{id}.asset";
data = AssetDatabase.LoadAssetAtPath<ScriptableObject>(soAssetPath);
bool isNew = false;
if (data == null)
{
data = CreateInstance(typeName + "Data");
isNew = true;
}
for (int i = 0; i < headers.Length && i < values.Length; i++)
{
string fieldName = CSVToCamelCase(headers[i]);
var field = data.GetType().GetField(fieldName);
if (field != null)
{
try
{
object value = ParseValue(values[i], field.FieldType);
field.SetValue(data, value);
}
catch (System.Exception e)
{
Debug.LogWarning($"[CSVToSOImporter] Failed to set {fieldName}: {e.Message}");
}
}
}
string prefabPath = $"Assets/Prefabs/{typeName}/{typeName}{id}.prefab";
Directory.CreateDirectory(Path.Combine(Application.dataPath, $"Prefabs/{typeName}"));
GameObject prefabInstance = GameObject.Instantiate(template);
prefabInstance.name = $"{typeName}{id}";
prefabSetup.SetupPrefab(prefabInstance, data);
GameObject prefabObj = PrefabUtility.SaveAsPrefabAsset(prefabInstance, prefabPath);
GameObject.DestroyImmediate(prefabInstance);
// Now set the prefab reference on data
if (data is BuildingData buildingData)
{
buildingData.prefab = prefabObj;
Debug.Log($"[CSVToSOImporter] Set prefab reference: {buildingData.name} -> {prefabObj.name}");
}
// Save data asset
if (isNew)
{
AssetDatabase.CreateAsset(data, soAssetPath);
}
else
{
EditorUtility.SetDirty(data);
}
// Force save assets to disk
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
return true;
}
private static void AutoConfigureBuildingManager()
{
BuildingManager buildingManager = GameObject.FindObjectOfType<BuildingManager>();
if (buildingManager == null)
{
Debug.LogError("<color=red>[CSVToSOImporter] BuildingManager not found in scene! Please add a BuildingManager component to a GameObject in your scene.</color>");
return;
}
// Load TowerData (which extends BuildingData)
string[] towerDataGuids = AssetDatabase.FindAssets("t:TowerData", new[] { "Assets/Data/ScriptableObjects" });
List<BuildingData> allTowers = new List<BuildingData>();
Debug.Log($"<color=cyan>[CSVToSOImporter] Found {towerDataGuids.Length} TowerData assets</color>");
foreach (string guid in towerDataGuids)
{
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
TowerData towerData = AssetDatabase.LoadAssetAtPath<TowerData>(assetPath);
if (towerData == null)
{
Debug.LogWarning($"[CSVToSOImporter] Failed to load TowerData: {assetPath}");
continue;
}
if (towerData.prefab == null)
{
Debug.LogWarning($"<color=yellow>[CSVToSOImporter] TowerData {towerData.name} has no prefab reference - skipping</color>");
continue;
}
allTowers.Add(towerData);
Debug.Log($"<color=green>[CSVToSOImporter] Added tower: {towerData.buildingName}</color>");
}
if (allTowers.Count == 0)
{
Debug.LogWarning("<color=yellow>[CSVToSOImporter] No TowerData with valid prefabs found!</color>");
Debug.LogWarning("<color=yellow>Run 'Northbound > Diagnose Tower System' to see what's wrong</color>");
return;
}
allTowers.Sort((a, b) => string.Compare(a.buildingName, b.buildingName));
buildingManager.availableBuildings.Clear();
foreach (var towerData in allTowers)
{
buildingManager.availableBuildings.Add(towerData);
}
EditorUtility.SetDirty(buildingManager);
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
Debug.Log($"<color=cyan>========================================</color>");
Debug.Log($"<color=cyan>🏗️ TOWER IMPORT COMPLETE!</color>");
Debug.Log($"<color=cyan>========================================</color>");
Debug.Log($"<color=green>✓ BuildingManager automatically configured!</color>");
Debug.Log($"<color=green>✓ Added {allTowers.Count} TowerData to availableBuildings list</color>");
Debug.Log($"<color=green>✓ Ready to play - all towers will appear in quickslot!</color>");
Debug.Log($"<color=cyan>========================================</color>");
foreach (var towerData in allTowers)
{
Debug.Log($"<color=green> - {towerData.buildingName}</color>");
}
Debug.Log($"<color=cyan>========================================</color>");
}
private static object ParseValue(string value, System.Type type)
{
if (string.IsNullOrEmpty(value))
{
return type.IsValueType ? System.Activator.CreateInstance(type) : null;
}
if (type == typeof(int))
{
int result;
if (int.TryParse(value, out result)) return result;
}
else if (type == typeof(float))
{
float result;
if (float.TryParse(value, out result)) return result;
}
else if (type == typeof(bool))
{
bool result;
if (bool.TryParse(value, out result)) return result;
}
else if (type == typeof(string))
{
return value;
}
return type.IsValueType ? System.Activator.CreateInstance(type) : null;
}
private static string CSVToCamelCase(string csvName)
{
if (string.IsNullOrEmpty(csvName))
return csvName;
string[] parts = csvName.Split('_');
for (int i = 1; i < parts.Length; i++)
{
if (!string.IsNullOrEmpty(parts[i]))
{
parts[i] = char.ToUpper(parts[i][0]) + parts[i].Substring(1);
}
}
return string.Join("", parts);
}
private static string[] ParseCSVLine(string line)
{
List<string> result = new List<string>();
bool inQuotes = false;
string current = "";
foreach (char c in line)
{
if (c == '"')
{
inQuotes = !inQuotes;
}
else if (c == ',' && !inQuotes)
{
result.Add(current);
current = "";
}
else
{
current += c;
}
}
result.Add(current);
return result.ToArray();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c00f900c9a822184dbb4dc85440d40dd

View File

@@ -2,6 +2,7 @@ using Unity.Netcode;
using UnityEditor;
using UnityEngine;
using UnityEngine.AI;
using Northbound;
namespace Northbound.Editor
{
@@ -147,9 +148,35 @@ namespace Northbound.Editor
private static void SetupTowerComponents(GameObject go)
{
Transform t = go.transform;
t.localPosition = Vector3.zero;
t.localRotation = Quaternion.identity;
t.localScale = Vector3.one;
if (go.GetComponent<NetworkObject>() == null)
go.AddComponent<NetworkObject>();
if (go.GetComponent<Building>() == null)
go.AddComponent<Building>();
if (go.GetComponent<TowerDataComponent>() == null)
go.AddComponent<TowerDataComponent>();
if (go.GetComponent<BoxCollider>() == null)
{
BoxCollider collider = go.AddComponent<BoxCollider>();
collider.size = new Vector3(1f, 2f, 1f);
collider.center = new Vector3(0f, 1f, 0f);
}
if (go.GetComponent<NavMeshObstacle>() == null)
{
NavMeshObstacle obstacle = go.AddComponent<NavMeshObstacle>();
obstacle.shape = NavMeshObstacleShape.Box;
obstacle.size = new Vector3(1f, 1f, 1f);
obstacle.center = new Vector3(0f, 0.5f, 0f);
}
int defaultLayer = LayerMask.NameToLayer("Default");
if (defaultLayer >= 0)
{

View File

@@ -0,0 +1,80 @@
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);
TowerDataComponent tower = prefab?.GetComponent<TowerDataComponent>();
string towerStatus = tower != null && tower.towerData != null ? "<color=green>✓</color>" : "<color=red>✗</color>";
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($"<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>");
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 069a105319ca9cf4a8323e1d5357960f

View File

@@ -0,0 +1,128 @@
using Northbound.Data;
using UnityEditor;
using UnityEngine;
using UnityEngine.AI;
namespace Northbound.Editor
{
public class TowerPrefabSetup : IPrefabSetup
{
public string GetTemplateName()
{
return "TowerTemplate";
}
public void SetupPrefab(GameObject prefab, ScriptableObject data)
{
if (!(data is TowerData towerData))
{
Debug.LogWarning($"[TowerPrefabSetup] Expected TowerData, got {data.GetType().Name}");
return;
}
var towerDataComponent = prefab.GetComponent<TowerDataComponent>();
if (towerDataComponent == null)
{
towerDataComponent = prefab.AddComponent<TowerDataComponent>();
Debug.Log($"[TowerPrefabSetup] Added TowerDataComponent component");
}
if (towerDataComponent != null)
{
towerDataComponent.towerData = towerData;
}
// TowerData now extends BuildingData, so set prefab reference
towerData.prefab = prefab;
// Ensure TowerData fields are synced to BuildingData
towerData.EnsureSynced();
Transform modelTransform = null;
if (!string.IsNullOrEmpty(towerData.modelPath))
{
RemoveOldModel(prefab);
if (towerData.modelPath.ToLower().EndsWith(".fbx"))
{
GameObject fbxModel = AssetDatabase.LoadAssetAtPath<GameObject>(towerData.modelPath);
if (fbxModel != null)
{
GameObject fbxInstance = GameObject.Instantiate(fbxModel);
fbxInstance.name = "Model";
fbxInstance.transform.SetParent(prefab.transform, false);
fbxInstance.transform.localPosition = Vector3.zero;
fbxInstance.transform.localRotation = Quaternion.identity;
// Set model scale based on sizeX/sizeY/sizeZ
fbxInstance.transform.localScale = new Vector3(towerData.sizeX, towerData.sizeZ, towerData.sizeY);
modelTransform = fbxInstance.transform;
Debug.Log($"[TowerPrefabSetup] Applied FBX model: {towerData.modelPath} with scale {towerData.sizeX}x{towerData.sizeZ}x{towerData.sizeY}");
}
else
{
Debug.LogWarning($"[TowerPrefabSetup] Could not load FBX model: {towerData.modelPath}");
}
}
else
{
var meshFilter = prefab.GetComponent<MeshFilter>();
if (meshFilter == null)
{
meshFilter = prefab.AddComponent<MeshFilter>();
}
var renderer = prefab.GetComponent<MeshRenderer>();
if (renderer == null)
{
renderer = prefab.AddComponent<MeshRenderer>();
}
Mesh mesh = AssetDatabase.LoadAssetAtPath<Mesh>(towerData.modelPath);
if (mesh != null)
{
meshFilter.sharedMesh = mesh;
modelTransform = renderer.transform;
modelTransform.localScale = new Vector3(towerData.sizeX, towerData.sizeZ, towerData.sizeY);
Debug.Log($"[TowerPrefabSetup] Applied mesh: {towerData.modelPath} with scale {towerData.sizeX}x{towerData.sizeZ}x{towerData.sizeY}");
}
else
{
Debug.LogWarning($"[TowerPrefabSetup] Could not load mesh: {towerData.modelPath}");
}
}
}
var collider = prefab.GetComponent<BoxCollider>();
if (collider == null)
{
collider = prefab.AddComponent<BoxCollider>();
}
collider.size = new Vector3(towerData.sizeX, towerData.sizeZ, towerData.sizeY);
collider.center = new Vector3(0f, towerData.sizeZ / 2f, 0f);
var navObstacle = prefab.GetComponent<NavMeshObstacle>();
if (navObstacle == null)
{
navObstacle = prefab.AddComponent<NavMeshObstacle>();
navObstacle.shape = NavMeshObstacleShape.Box;
}
navObstacle.size = new Vector3(towerData.sizeX, towerData.sizeZ, towerData.sizeY);
navObstacle.center = new Vector3(0f, towerData.sizeZ / 2f, 0f);
}
private void RemoveOldModel(GameObject prefab)
{
Transform oldModel = prefab.transform.Find("Model");
if (oldModel != null)
{
GameObject.DestroyImmediate(oldModel.gameObject);
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ea17487cde4842d45baf5eb92943142a

View File

@@ -0,0 +1,26 @@
using Northbound.Data;
using Unity.Netcode;
using UnityEngine;
namespace Northbound
{
[RequireComponent(typeof(Building))]
[RequireComponent(typeof(NetworkObject))]
public class TowerDataComponent : MonoBehaviour
{
[Header("Data Reference")]
[Tooltip("ScriptableObject containing tower data")]
public TowerData towerData;
private void Awake()
{
// TowerData now extends BuildingData, so just pass it directly
Building building = GetComponent<Building>();
if (building != null && towerData != null)
{
building.buildingData = towerData;
building.initialTeam = TeamType.Player;
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 56c4536effc49fe47af593bf9d17e979