// -------------------------------------------------------------------------- GetStyleSheet // -- The StyleSheet is used for styling the AAI editor windows -- // -- GetStyleSheet ----------------------------------------------------------------------- public void BuildStyleSheet(bool refresh = false) { if (aaiStyleSheets.Count != 0 && !refresh) { return; } aaiStyleSheets.Clear(); aaiStyleSheetsDictionary.Clear(); aaiStyleSheets = GetStylesheet(refresh); for (var i = 0; i < aaiStyleSheets.Count; i++) { aaiStyleSheetsDictionary.TryAddValue(aaiStyleSheets[i].name, aaiStyleSheets[i]); } }
// ------------------------------------------------------------ GetFieldData // -- Get field and type data from the editor target class -- // -- GetFieldData --------------------------------------------------------- private SerializedDictionary <string, ClassData> GetFieldData() { if (idConfig.AAIConfiguration().refreshClassData) { idConfig.AAIConfiguration().classDataDictionary = new SerializedDictionary <string, ClassData>(); } var needsRefresh = idConfig.AAIConfiguration().refreshClassData; var thisName = this.GetType().Name; var targetName = target.GetType().Name; var classDict = new SerializedDictionary <string, ClassData>(); // --------------------------------------------- Experimental // -- Check for existing saved Target data ------------------ if (idConfig.AAIConfiguration().classDataDictionary.TryGetValue(targetName, out var tmpClassData) && !needsRefresh) { classDict.TryAddValue(targetName, tmpClassData); if (defaultEditorDebug) { Debug.Log($"Target: {classDict[targetName].typeName} Retrieved from Config"); } } // ----------------------------------------- Current Default // -- If it does not exist, create it ---------------------- else { var attributes = target.GetType().GetClassFields(true); classDict.TryAddValue(targetName, attributes); } // --------------------------------------------- Experimental // -- Check for existing saved Editor data ------------------ if (idConfig.AAIConfiguration().classDataDictionary.TryGetValue(thisName, out var tmpEditorClassData) && !needsRefresh) { classDict.TryAddValue(thisName, tmpEditorClassData); if (defaultEditorDebug) { Debug.Log($"Editor: {classDict[thisName].typeName} Retrieved from Config"); } } // ----------------------------------------- Current Default // -- If it does not exist, create it ---------------------- else { var attributes = this.GetEditorAttributes(); classDict.TryAddValue(thisName, attributes); } // -- Configure categories ----------------------------------- var classData = classDict[targetName]; // -- Locate Default category, remove it, reorder the -------- // -- categories as desired, replace Default at the end ------ UICategory defaultCategory; try { classData.categoryList = classData.categoryList.Where(x => !(x is null) || !x.category.StartsWith(" ")).ToList(); defaultCategory = classData.categoryList.Find(x => x.category == "Default"); } catch (Exception e) { Debug.Log(e); idConfig.AAIConfiguration().refreshClassData = true; GetFieldData(); return(null); } isAnimated = idConfig.AAIConfiguration().enableAnimation; if (classData.categoryList.Count < 1) { return(classDict); } { classData.categoryList.RemoveAll(x => Equals(x, defaultCategory)); classData.categoryList = classData.categoryList.OrderBy(x => x.order).ToList(); classData.categoryList.TryAddValue(defaultCategory); classData.categoryList.ForEach(x => { bool expand; expand = idConfig.AAIConfiguration().expandCategoriesByDefault || x.expand || classData.categoryList.Count == 1; if (isAnimated) { var element = new AnimatedFoldout { name = x.category, text = x.category, value = false }; if (!categoryList.Exists(c => c.name == element.name)) { categoryList.TryAddValue(element); } } else { var element = new Foldout { name = x.category, text = x.category, value = expand }; if (!categoryList.Exists(c => c.name == element.name)) { categoryList.TryAddValue(element); } } }); } return(classDict); }