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