Example #1
0
        private void OnDeleteClick()
        {
            switch (funcTab.SelectedIndex)
            {
            case 1:
                if (selectedItems != null)
                {
                    if (!settings.useDatabase)
                    {
                        if (EditorUtility.DisplayDialog("删除选中道具", $"确定将选中道具放入回收站吗?", "确定", "取消"))
                        {
                            List <string> failedPaths = new List <string>();
                            AssetDatabase.MoveAssetsToTrash(selectedItems.Select(x => AssetDatabase.GetAssetPath(x)).ToArray(), failedPaths);
                        }
                    }
                    else if (EditorUtility.DisplayDialog("删除选中道具", $"确定将选中道具从数据库中删除吗?此操作将不可逆!", "确定", "取消"))
                    {
                        bool success = false;
                        foreach (var item in selectedItems)
                        {
                            if (ItemDatabase.Editor.DeleteItem(item))
                            {
                                items.Remove(item);
                                success = true;
                            }
                        }
                        if (success)
                        {
                            itemList.ClearSelection();
                            itemList.RefreshItems();
                            rightPanel.Clear();
                        }
                    }
                }
                break;

            case 2:
                if (selectedTemplates != null)
                {
                    if (EditorUtility.DisplayDialog("删除选中模板", $"确定将选中模板放入回收站吗?", "确定", "取消"))
                    {
                        bool success = false;
                        foreach (var template in selectedTemplates)
                        {
                            if (AssetDatabase.MoveAssetToTrash(AssetDatabase.GetAssetPath(template)))
                            {
                                templates.Remove(template);
                                success = true;
                            }
                        }
                        if (success)
                        {
                            templateList.ClearSelection();
                            templateList.RefreshItems();
                            rightPanel.Clear();
                        }
                    }
                }
                break;
            }
        }
Example #2
0
        private void DoSearchDropdown(string keyword = null)
        {
            searchDropdown.style.display = new StyleEnum <DisplayStyle>(string.IsNullOrEmpty(keyword) ? DisplayStyle.None : DisplayStyle.Flex);
            if (!string.IsNullOrEmpty(keyword))
            {
                switch (funcTab.SelectedIndex)
                {
                case 1:
                    switch (keyType)
                    {
                    case SearchKeyType.SearchID:
                        var results = items.FindAll(x => x.ID.Contains(keyword));
                        searchDropdown.itemsSource = results;
                        searchDropdown.bindItem    = (e, i) =>
                        {
                            (e as Label).text = $"{results[i].Name}\n(ID: {ZetanUtility.Editor.HighlightContentByKey(results[i].ID, keyword, results[i].ID.Length)})";
                        };
                        searchDropdown.RefreshItems();
                        break;

                    case SearchKeyType.SearchName:
                        results = items.FindAll(x => x.Name.Contains(keyword));
                        searchDropdown.itemsSource = results;
                        searchDropdown.bindItem    = (e, i) =>
                        {
                            (e as Label).text = ZetanUtility.Editor.HighlightContentByKey(results[i].Name, keyword, results[i].Name.Length);
                        };
                        searchDropdown.RefreshItems();
                        break;

                    case SearchKeyType.SearchDescription:
                        results = items.FindAll(x => x.Description.Contains(keyword));
                        searchDropdown.itemsSource = results;
                        searchDropdown.bindItem    = (e, i) =>
                        {
                            (e as Label).text = $"{results[i].Name}\n(描述: {ZetanUtility.Editor.HighlightContentByKey(results[i].Description, keyword, 30)})";
                        };
                        searchDropdown.RefreshItems();
                        break;
                    }
                    break;

                case 2:
                    switch (keyType)
                    {
                    case SearchKeyType.SearchID:
                        var results = templates.FindAll(x => x.IDPrefix.Contains(keyword));
                        searchDropdown.itemsSource = results;
                        searchDropdown.bindItem    = (e, i) =>
                        {
                            (e as Label).text = $"{results[i].Name}\n(ID前缀: {ZetanUtility.Editor.HighlightContentByKey(results[i].IDPrefix, keyword, results[i].IDPrefix.Length)})";
                        };
                        searchDropdown.RefreshItems();
                        break;

                    case SearchKeyType.SearchName:
                        results = templates.FindAll(x => x.Name.Contains(keyword));
                        searchDropdown.itemsSource = results;
                        searchDropdown.bindItem    = (e, i) =>
                        {
                            (e as Label).text = ZetanUtility.Editor.HighlightContentByKey(results[i].Name, keyword, results[i].Name.Length);
                        };
                        searchDropdown.RefreshItems();
                        break;
                    }
                    break;
                }
            }
        }