using System;
using System.Collections.Generic;
using UnityEditor;

namespace Jovian.TagSystem.Editor {
    public static class JovianTagsEditorUtility {
        public static JovianTagsSettings[] GetSettings() {
            var settingsPaths = AssetDatabase.FindAssets("t:JovianTagsSettings");
            if(settingsPaths.Length == 0) {
                return Array.Empty<JovianTagsSettings>();
            }

            var tagSettings = new List<JovianTagsSettings>();
            for(int i = 0, n = settingsPaths.Length; i < n; i++) {
                var guid = settingsPaths[i];
                var path = AssetDatabase.GUIDToAssetPath(guid);
                var setting = AssetDatabase.LoadAssetAtPath<JovianTagsSettings>(path);
                tagSettings.Add(setting);
            }

            return tagSettings.ToArray();
        }
    }
}
