﻿using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using UnityEditor;
using UnityEngine;

namespace AKLib.LebenEngine
{
    //=======================================================
    /// <summary>
    /// LebenNoteクラス
    /// 内容:LebenScript編集Editor拡張クラス
    /// </summary>
    //=======================================================
    public class LebenNote : EditorWindow
    {
        private static LebenNote _lebenNote;
        private static List<LebenScript> _listLebenScripts;

        //=======================================================
        /// <summary>
        /// LebenNoteを開きます
        /// </summary>
        //=======================================================
        [MenuItem("LebenEngine/Widow/Leben Note")]
        private static void ShowWindow()
        {
            if (_lebenNote == null) _lebenNote = GetWindow<LebenNote>();
            _listLebenScripts = FindLebenScripts();
            _lebenNote.Show();
        }

        //=======================================================
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        //=======================================================
        private static List<LebenScript> FindLebenScripts()
        {
            var guids = AssetDatabase.FindAssets("t:prefab", null);
            List<LebenScript> scripts = new List<LebenScript>();
            foreach (var guid in guids)
            {
                string path = AssetDatabase.GUIDToAssetPath(guid);
                LebenScript script = AssetDatabase.LoadAssetAtPath<LebenScript>(path);
                if (script != null) scripts.Add(script);
            }
            return scripts;
        }

        //=======================================================
        /// <summary>
        /// GUI表示
        /// </summary>
        //=======================================================
        private void OnGUI()
        {
        }
    }
}