Files
Northbound/Assets/Scripts/Editor/EnemyPortalEditor.cs
dal4segno 2593b6dd37 데이터 파이프라인 개선 및 포탈 로직 생성
csv import 시 자동으로 완전한 프리팹이 생성될 수 있도록 함.
2026-02-01 00:29:22 +09:00

78 lines
2.6 KiB
C#

using Northbound;
using Northbound.Data;
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.Linq;
[CustomEditor(typeof(EnemyPortal))]
public class EnemyPortalEditor : Editor
{
private const string MONSTER_PREFAB_FOLDER = "Assets/Prefabs/Monster";
public override void OnInspectorGUI()
{
DrawDefaultInspector();
EnemyPortal portal = (EnemyPortal)target;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Monster Data Loader", EditorStyles.boldLabel);
if (GUILayout.Button("Load Monster Data"))
{
LoadMonsterData(portal);
}
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:Prefab", new[] { MONSTER_PREFAB_FOLDER });
List<EnemyPortal.MonsterEntry> entries = new List<EnemyPortal.MonsterEntry>();
int loadedCount = 0;
foreach (string guid in guids)
{
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
if (prefab != null)
{
MonsterDataComponent monsterDataComponent = prefab.GetComponent<MonsterDataComponent>();
if (monsterDataComponent != null && monsterDataComponent.monsterData != null)
{
entries.Add(new EnemyPortal.MonsterEntry
{
prefab = prefab
});
loadedCount++;
}
else
{
Debug.LogWarning($"[EnemyPortal] Prefab {prefab.name} does not have MonsterDataComponent with valid monsterData reference");
}
}
}
serializedObject.Update();
SerializedProperty entriesProperty = serializedObject.FindProperty("monsterEntries");
entriesProperty.ClearArray();
entriesProperty.arraySize = entries.Count;
for (int i = 0; i < entries.Count; i++)
{
SerializedProperty element = entriesProperty.GetArrayElementAtIndex(i);
element.FindPropertyRelative("prefab").objectReferenceValue = entries[i].prefab;
}
serializedObject.ApplyModifiedProperties();
AssetDatabase.SaveAssets();
Debug.Log($"[EnemyPortal] Loaded {loadedCount} monsters from {MONSTER_PREFAB_FOLDER}");
}
}