From a3945d6aa50ea2f3254b97bf61ce631b74b7c543 Mon Sep 17 00:00:00 2001 From: zhang hongbo Date: Tue, 10 Feb 2026 18:32:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98Item=E6=97=B6=E5=B8=A6?= =?UTF-8?q?=E4=B8=8A=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor.meta | 2 +- .../Editor/Design_Tools/ItemConfigEditor.cs | 36 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Scripts/Editor.meta b/Scripts/Editor.meta index d51de57..2eb0e89 100644 --- a/Scripts/Editor.meta +++ b/Scripts/Editor.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5706044f5f8a1d9469a0d192ad6a6da8 +guid: 9d4c2e3c55b93e940bdd8c2cdc1605bf folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Scripts/Editor/Design_Tools/ItemConfigEditor.cs b/Scripts/Editor/Design_Tools/ItemConfigEditor.cs index 41bdd8a..5f48421 100644 --- a/Scripts/Editor/Design_Tools/ItemConfigEditor.cs +++ b/Scripts/Editor/Design_Tools/ItemConfigEditor.cs @@ -1624,6 +1624,31 @@ namespace DesignTools currentPage = totalPages - 1; } + /// + /// 根据Res字段获取完整资源路径 + /// + private string GetFullResourcePath(string res) + { + if (string.IsNullOrEmpty(res)) return ""; + + string[] parts = res.Split(','); + if (parts.Length < 2) return ""; + + if (!int.TryParse(parts[0], out int tableId)) return ""; + if (!int.TryParse(parts[1], out int itemId)) return ""; + + if (itemId < 0) return ""; // 未选择Item + + var table = allArtTables.FirstOrDefault(x => x.TableId == tableId); + if (table == null) return ""; + + var item = table.Items.FirstOrDefault(x => x.Id == itemId); + if (item == null) return ""; + if (item.Sprite == null) return ""; + + return AssetDatabase.GetAssetPath(item.Sprite); + } + /// /// 保存数据到Excel /// @@ -1671,7 +1696,7 @@ namespace DesignTools var worksheet = package.Workbook.Worksheets[ITEM_SHEET_NAME]; // 找到列索引 - int idCol = -1, nameCol = -1, iTypeCol = -1, effectCol = -1, resCol = -1; + int idCol = -1, nameCol = -1, iTypeCol = -1, effectCol = -1, resCol = -1, fullResourcePathCol = -1; int columnCount = worksheet.Dimension.Columns; for (int col = 1; col <= columnCount; col++) @@ -1682,6 +1707,7 @@ namespace DesignTools else if (header == "IType") iTypeCol = col; else if (header == "Effect") effectCol = col; else if (header == "Res") resCol = col; + else if (header == "FullResourcePath") fullResourcePathCol = col; } // 创建Id到行号的映射(读取现有数据) @@ -1729,6 +1755,13 @@ namespace DesignTools { worksheet.Cells[targetRow, resCol].Value = item.Res; } + + // 写入完整资源路径 + if (fullResourcePathCol > 0) + { + string fullPath = GetFullResourcePath(item.Res); + worksheet.Cells[targetRow, fullResourcePathCol].Value = fullPath; + } } // 删除已不存在的数据行(只清空我们管理的列) @@ -1746,6 +1779,7 @@ namespace DesignTools worksheet.Cells[row, iTypeCol].Value = null; if (effectCol > 0) worksheet.Cells[row, effectCol].Value = null; if (resCol > 0) worksheet.Cells[row, resCol].Value = null; + if (fullResourcePathCol > 0) worksheet.Cells[row, fullResourcePathCol].Value = null; } } }