using System.Collections; using System.Collections.Generic; using UnityEngine; using RPGCreationKit; using UnityEditor; namespace RPGCreationKit { [System.Serializable] public class FactionsDatabaseDictionary : SerializableDictionary { } [CreateAssetMenu(fileName = "New Factions Database", menuName = "RPG Creation Kit/Databases/New Factions Database", order = 1)] public class FactionsDatabaseFile : RckDatabase { [SerializeField] private List allFactions = new List(); public FactionsDatabaseDictionary dictionary; #if UNITY_EDITOR [ContextMenu("Fill With All Items")] public override void fill() { dictionary.Clear(); allFactions = GetAllInstances(); for (int i = 0; i < allFactions.Count; i++) { if (allFactions[i] != null) { Debug.Log(i + " " + allFactions[i].name); dictionary.Add(allFactions[i].ID, allFactions[i]); } } } public static List GetAllInstances() where T : Faction { string[] guids = AssetDatabase.FindAssets("t:" + typeof(T).Name); List a = new List(guids.Length); for (int i = 0; i < guids.Length; i++) { string path = AssetDatabase.GUIDToAssetPath(guids[i]); a.Add(AssetDatabase.LoadAssetAtPath(path)); } return a; } #endif } }