using System.Collections; using System.Collections.Generic; using UnityEngine; using RPGCreationKit; using RPGCreationKit.CellsSystem; using UnityEditor; namespace RPGCreationKit { [System.Serializable] public class WorldspacesDatabaseDictionary : SerializableDictionary { } [CreateAssetMenu(fileName = "New Worldspace Database", menuName = "RPG Creation Kit/Databases/New Worldspace Database", order = 1)] public class WorldspaceDatabaseFile : RckDatabase { [SerializeField] private List allItems = new List(); public WorldspacesDatabaseDictionary dictionary; #if UNITY_EDITOR [ContextMenu("Fill With All Items")] public override void fill() { dictionary.Clear(); allItems = GetAllInstances(); for (int i = 0; i < allItems.Count; i++) { if (allItems[i] != null) { Debug.Log(i + " " + allItems[i].name); dictionary.Add(allItems[i].worldSpaceID, allItems[i]); } } } public static List GetAllInstances() where T : Worldspace { 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 } }