데이터 파이프라인 개선 및 포탈 로직 생성
csv import 시 자동으로 완전한 프리팹이 생성될 수 있도록 함.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using Northbound;
|
||||
using Northbound.Data;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
@@ -6,7 +8,7 @@ using System.Linq;
|
||||
[CustomEditor(typeof(EnemyPortal))]
|
||||
public class EnemyPortalEditor : Editor
|
||||
{
|
||||
private const string MONSTER_DATA_FOLDER = "Assets/Data/ScriptableObjects/Monster";
|
||||
private const string MONSTER_PREFAB_FOLDER = "Assets/Prefabs/Monster";
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
@@ -22,12 +24,12 @@ public class EnemyPortalEditor : Editor
|
||||
LoadMonsterData(portal);
|
||||
}
|
||||
|
||||
EditorGUILayout.HelpBox("Click 'Load Monster Data' to automatically load all monsters from " + MONSTER_DATA_FOLDER, MessageType.Info);
|
||||
EditorGUILayout.HelpBox("Click 'Load Monster Data' to automatically load all monster prefabs from " + MONSTER_PREFAB_FOLDER, MessageType.Info);
|
||||
}
|
||||
|
||||
private void LoadMonsterData(EnemyPortal portal)
|
||||
{
|
||||
string[] guids = AssetDatabase.FindAssets("t:MonsterData", new[] { MONSTER_DATA_FOLDER });
|
||||
string[] guids = AssetDatabase.FindAssets("t:Prefab", new[] { MONSTER_PREFAB_FOLDER });
|
||||
|
||||
List<EnemyPortal.MonsterEntry> entries = new List<EnemyPortal.MonsterEntry>();
|
||||
int loadedCount = 0;
|
||||
@@ -35,24 +37,23 @@ public class EnemyPortalEditor : Editor
|
||||
foreach (string guid in guids)
|
||||
{
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
Northbound.Data.MonsterData monsterData = AssetDatabase.LoadAssetAtPath<Northbound.Data.MonsterData>(assetPath);
|
||||
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
|
||||
|
||||
if (monsterData != null)
|
||||
if (prefab != null)
|
||||
{
|
||||
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(monsterData.prefabPath);
|
||||
MonsterDataComponent monsterDataComponent = prefab.GetComponent<MonsterDataComponent>();
|
||||
|
||||
if (prefab != null)
|
||||
if (monsterDataComponent != null && monsterDataComponent.monsterData != null)
|
||||
{
|
||||
entries.Add(new EnemyPortal.MonsterEntry
|
||||
{
|
||||
monsterData = monsterData,
|
||||
prefab = prefab
|
||||
});
|
||||
loadedCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[EnemyPortal] Could not load prefab at path: {monsterData.prefabPath} for monster {monsterData.id}");
|
||||
Debug.LogWarning($"[EnemyPortal] Prefab {prefab.name} does not have MonsterDataComponent with valid monsterData reference");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,13 +66,12 @@ public class EnemyPortalEditor : Editor
|
||||
for (int i = 0; i < entries.Count; i++)
|
||||
{
|
||||
SerializedProperty element = entriesProperty.GetArrayElementAtIndex(i);
|
||||
element.FindPropertyRelative("monsterData").objectReferenceValue = entries[i].monsterData;
|
||||
element.FindPropertyRelative("prefab").objectReferenceValue = entries[i].prefab;
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
Debug.Log($"[EnemyPortal] Loaded {loadedCount} monsters from {MONSTER_DATA_FOLDER}");
|
||||
Debug.Log($"[EnemyPortal] Loaded {loadedCount} monsters from {MONSTER_PREFAB_FOLDER}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user