69 lines
2.2 KiB
C#
69 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using BriarQueen.Data.Identifiers;
|
|
using BriarQueen.Framework.Managers.Player.Data;
|
|
using BriarQueen.Framework.Registries;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace BriarQueen.Editor.Drawers.Registries
|
|
{
|
|
[CustomEditor(typeof(CodexRegistry))]
|
|
public class CodexRegistryFill : UnityEditor.Editor
|
|
{
|
|
public override void OnInspectorGUI()
|
|
{
|
|
DrawDefaultInspector();
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
if (GUILayout.Button("Discover Codex Entry Assets"))
|
|
{
|
|
Populate((CodexRegistry)target);
|
|
}
|
|
}
|
|
|
|
private static void Populate(CodexRegistry registry)
|
|
{
|
|
string[] guids = AssetDatabase.FindAssets("t:CodexEntrySo");
|
|
|
|
var books = new List<CodexEntrySo>();
|
|
var clues = new List<CodexEntrySo>();
|
|
var photos = new List<CodexEntrySo>();
|
|
|
|
foreach (string guid in guids)
|
|
{
|
|
string path = AssetDatabase.GUIDToAssetPath(guid);
|
|
var entry = AssetDatabase.LoadAssetAtPath<CodexEntrySo>(path);
|
|
|
|
if (entry == null)
|
|
continue;
|
|
|
|
switch (entry.EntryType)
|
|
{
|
|
case CodexType.BookEntry:
|
|
books.Add(entry);
|
|
break;
|
|
|
|
case CodexType.PuzzleClue:
|
|
clues.Add(entry);
|
|
break;
|
|
|
|
case CodexType.Photo:
|
|
photos.Add(entry);
|
|
break;
|
|
}
|
|
}
|
|
|
|
books.Sort((a, b) => string.CompareOrdinal(a.name, b.name));
|
|
clues.Sort((a, b) => string.CompareOrdinal(a.name, b.name));
|
|
photos.Sort((a, b) => string.CompareOrdinal(a.name, b.name));
|
|
|
|
Undo.RecordObject(registry, "Discover Codex Assets");
|
|
registry.SetDiscoveredEntries(books, clues, photos);
|
|
EditorUtility.SetDirty(registry);
|
|
AssetDatabase.SaveAssets();
|
|
|
|
Debug.Log($"[AssetRegistry] Discovery complete. Books: {books.Count}, Clues: {clues.Count}, Photos: {photos.Count}");
|
|
}
|
|
}
|
|
} |