コード例 #1
0
        protected virtual void RenderItemHeader(Template template)
        {
            var db           = EditorAssetLoader.GetDB();
            var currentLabel = Functions.ExtractNameFromType(template.GetType());

            if (currentLabel != lastLabel && db.SelectedSort == SortOption.TYPES)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(currentLabel, EditorStyles.boldLabel);
                Style.Spacing();
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            bool prevValue = template.Show;

            var label = Style.RichTextLabelType(template.Name, null, template.GetType());

            template.Show = EditorGUILayout.Foldout(
                template.Show,
                $"<color={Style.GetHexFromColor(Style.Secondary)}>{template.ID}</color> {label}",
                true,
                new GUIStyle(EditorStyles.foldout)
            {
                richText = true
            });

            if (template.Show != prevValue)
            {
                DatabaseWindow.SetActiveRecord(template.Show ? template.ID : -1);
            }


            lastLabel = currentLabel;
            if (Style.ToolBarButton("Clone", Status.Secondary))
            {
                var newTemplate = DatabaseWindow.ActiveCollection.Clone(template);
                DatabaseWindow.SetActiveRecord(newTemplate.ID);
            }
            if (Style.ToolBarButton("Delete", Status.Danger))
            {
                DatabaseWindow.ActiveCollection.Remove(template);
            }
            EditorGUILayout.EndHorizontal();
        }
コード例 #2
0
        protected virtual List <Template> GetCollectionTemplates()
        {
            var db         = EditorAssetLoader.GetDB();
            var collection = DatabaseWindow.ActiveCollection;
            var list       = db.Get(collection.GetType()).List();

            switch (db.SelectedSort)
            {
            case SortOption.AZ:
            {
                list = list.OrderBy(x => x.ID).ToList();
                break;
            }

            case SortOption.ZA:
            {
                list = list.OrderByDescending(x => x.ID).ToList();
                break;
            }

            case SortOption.TYPES:
            {
                list = list.OrderBy(x => x.GetType().ToString()).ToList();
                break;
            }

            default: break;
            }

            if (!String.IsNullOrEmpty(db.SearchQuery))
            {
                list = list.Where(x => x.Name.IndexOf(db.SearchQuery, 0, StringComparison.CurrentCultureIgnoreCase) != -1).ToList();
            }

            return(list);
        }