From 74449e09a226de76b2587a3427bf0326d7dff173 Mon Sep 17 00:00:00 2001 From: zhang hongbo Date: Wed, 4 Feb 2026 10:34:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Art_SubModule | 2 +- .../DecorateConfigEditor/CHANGELOG.md | 273 - .../DecorateConfigEditor/CHANGELOG.md.meta | 7 - .../DecorateConfigEditor.cs | 4954 ----------------- .../DecorateConfigEditor.cs.meta | 11 - .../DecorateConfigEditor.uxml | 139 - .../DecorateConfigEditor.uxml.meta | 10 - .../DecorateCostTableConverter.cs | 234 - .../DecorateCostTableConverter.cs.meta | 11 - .../DecorateConfigEditor/QUICKREF.md | 96 - .../DecorateConfigEditor/QUICKREF.md.meta | 7 - .../README_SO_Integration.md | 236 - .../README_SO_Integration.md.meta | 7 - 13 files changed, 1 insertion(+), 5986 deletions(-) delete mode 100644 Assets/Editor/CustomTools/DecorateConfigEditor/CHANGELOG.md delete mode 100644 Assets/Editor/CustomTools/DecorateConfigEditor/CHANGELOG.md.meta delete mode 100644 Assets/Editor/CustomTools/DecorateConfigEditor/DecorateConfigEditor.cs delete mode 100644 Assets/Editor/CustomTools/DecorateConfigEditor/DecorateConfigEditor.cs.meta delete mode 100644 Assets/Editor/CustomTools/DecorateConfigEditor/DecorateConfigEditor.uxml delete mode 100644 Assets/Editor/CustomTools/DecorateConfigEditor/DecorateConfigEditor.uxml.meta delete mode 100644 Assets/Editor/CustomTools/DecorateConfigEditor/DecorateCostTableConverter.cs delete mode 100644 Assets/Editor/CustomTools/DecorateConfigEditor/DecorateCostTableConverter.cs.meta delete mode 100644 Assets/Editor/CustomTools/DecorateConfigEditor/QUICKREF.md delete mode 100644 Assets/Editor/CustomTools/DecorateConfigEditor/QUICKREF.md.meta delete mode 100644 Assets/Editor/CustomTools/DecorateConfigEditor/README_SO_Integration.md delete mode 100644 Assets/Editor/CustomTools/DecorateConfigEditor/README_SO_Integration.md.meta diff --git a/Assets/Art_SubModule b/Assets/Art_SubModule index e1f7ea5..ab2ea01 160000 --- a/Assets/Art_SubModule +++ b/Assets/Art_SubModule @@ -1 +1 @@ -Subproject commit e1f7ea568b27493475d39eeef68fb4407d43928f +Subproject commit ab2ea01d2aede712e859db9c794e14f284f3a275 diff --git a/Assets/Editor/CustomTools/DecorateConfigEditor/CHANGELOG.md b/Assets/Editor/CustomTools/DecorateConfigEditor/CHANGELOG.md deleted file mode 100644 index ba4571f..0000000 --- a/Assets/Editor/CustomTools/DecorateConfigEditor/CHANGELOG.md +++ /dev/null @@ -1,273 +0,0 @@ -# DecorateConfigEditor 修改清单 - -## 版本更新日期:2025-12-26 - ---- - -## 📋 功能限制 - -### 1. AreaId 限制 -- **限制内容**:禁止编辑 AreaId = 1 或 2 的配置 -- **实现位置**: - - `OnLoadConfigClicked()` - 读取配置时检查 - - `OnSaveConfigClicked()` - 保存配置时检查 - - `CreateNewAreaConfig()` - 创建新场景时检查 -- **提示信息**:"AreaId 1 和 2 包含特殊处理,不支持通过此工具编辑。如需修改请联系编辑器作者。" -- **原因**:AreaId 1和2包含特殊处理逻辑,避免误操作 - -### 2. 步骤数量限制 -- **限制内容**:步骤数量固定为 25,不允许修改 -- **实现位置**: - - `BindUIControls()` - UI加载时禁用步骤数量输入框 - - `OnLoadConfigClicked()` - 强制设置为25 - - `CreateNewAreaConfig()` - 新场景默认25步 - - UXML界面 - 添加提示文字:"不可修改,如需调整请联系编辑器作者" -- **UI表现**:StepCountField 输入框禁用(灰色不可编辑) - -### 3. 不存在的AreaId处理 -- **处理逻辑**: - - 读取配置时,如果指定的AreaId不存在,弹出提示框 - - 提示信息:"未找到AreaId=X的配置。如需创建新场景,请点击'创建新场景'按钮。" - - **不进行任何自动创建**,只提示用户 -- **实现位置**:`OnLoadConfigClicked()` - -### 4. 创建新场景流程 -- **新增按钮**:"创建新场景"按钮(在配置管理区域) -- **操作流程**: - 1. 点击"创建新场景"按钮 - 2. 弹出输入对话框,要求输入AreaId - 3. 验证AreaId(不能是1或2,不能是已存在的) - 4. 创建25个默认步骤配置 - 5. 自动记录bg初始状态(如果bg节点已设置) - 6. 允许用户进行编辑 - 7. **此时配置未保存到文件**,需要手动点击"保存配置" -- **新增类**:`InputDialogWindow` - 用于输入AreaId的弹窗 - ---- - -## 🎯 Spine相关特殊处理 - -### 1. UI中隐藏Spine操作 -- **实现位置**:`ParseAndCreateActionGroups()` -- **处理逻辑**: - ```csharp - // 跳过所有spine相关操作,用户不可见不可编辑 - if (actionType.Contains("spine")) continue; - ``` -- **支持的spine类型**: - - `init_spine` - 初始化spine - - `replace_spine` - 替换spine - - 任何包含"spine"关键字的操作 - -### 2. 保存时保留Spine配置 -- **实现位置**:`UpdateRowActionString()` -- **处理逻辑**: - 1. 从原始Action字符串中提取所有spine操作 - 2. 将spine操作放在新Action字符串的**最前面** - 3. 后面跟用户编辑的其他操作 -- **代码示例**: - ```csharp - // 保存原有的spine操作(放在最前面) - List spineActions = new List(); - if (!string.IsNullOrEmpty(row.Action)) - { - string[] oldActions = row.Action.Split('@'); - foreach (string oldAction in oldActions) - { - if (oldAction.Contains("spine")) - { - spineActions.Add(oldAction); - } - } - } - // 先添加spine操作 - actionStrings.AddRange(spineActions); - ``` - -### 3. 场景还原时跳过Spine -- **实现位置**: - - `ApplyInitAction()` - 跳过 init_spine - - `ApplyStepAction()` - 跳过所有spine操作 -- **效果**:用户在预览场景时,spine相关操作不会执行,但配置保持完整 - ---- - -## ✨ 新增功能 - -### 1. reset_pos 操作支持 -- **操作格式**:`reset_pos#节点路径,x=y` -- **示例**:`reset_pos#bg/clearObj/my_sg_2,-156=-838` -- **功能**:重置指定GameObject的位置(RectTransform.anchoredPosition) - -#### UI实现: -- **类型**:固定2个字段 - - ObjectField:选择目标GameObject - - TextField:输入位置坐标(格式:x=y,如:-156=-838) -- **位置**:与clear、add、replace、replace_image并列 -- **添加按钮**:"+ ResetPos" - -#### 代码实现: -1. **CreateActionGroup()** - 创建reset_pos UI组 - ```csharp - else if (actionType == "reset_pos") - { - ObjectField objField = new ObjectField("目标节点:"); - TextField posField = new TextField("位置(x=y):"); - } - ``` - -2. **ParseAndCreateActionGroups()** - 解析现有reset_pos配置 - ```csharp - else if (actionType == "reset_pos") - { - string[] pathParts = paths.Split(','); - // 解析节点和位置 - } - ``` - -3. **UpdateRowActionString()** - 生成reset_pos字符串 - ```csharp - else if (actionType == "reset_pos") - { - actionStrings.Add($"reset_pos#{targetPath},{position}"); - } - ``` - -4. **ApplyResetPosAction()** - 应用reset_pos操作 - ```csharp - private void ApplyResetPosAction(string paths) - { - // 解析x=y格式 - string[] posParts = positionStr.Split('='); - rt.anchoredPosition = new Vector2(x, y); - } - ``` - -### 2. 只读Action字符串显示 -- **位置**:每个步骤编辑区域的顶部 -- **显示内容**:当前步骤的完整Action配置字符串 -- **特性**: - - 只读(不可编辑) - - 灰色显示(opacity: 0.7) - - 多行显示(multiline) - - 实时更新:当用户编辑操作组时,自动更新显示 -- **UI元素名称**:`ActionDisplay` -- **更新位置**:`UpdateRowActionString()` 末尾 - ---- - -## 🔧 代码结构优化 - -### 新增文件 -无新增文件,所有修改在现有文件中 - -### 新增类 -1. **InputDialogWindow**(EditorWindow) - - 用途:创建新场景时输入AreaId - - 包含字段: - - `message` - 提示信息 - - `inputValue` - 用户输入的值 - - `confirmed` - 是否确认 - - 方法:`OnGUI()` - 绘制输入界面 - -### 新增方法 -1. **OnCreateNewSceneClicked()** - 处理"创建新场景"按钮点击 -2. **ShowInputDialog()** - 显示输入对话框 -3. **ApplyResetPosAction()** - 应用reset_pos操作 - -### 修改的方法 -1. **BindUIControls()** - 禁用步骤数量输入框 -2. **OnLoadConfigClicked()** - 添加AreaId和配置存在检查 -3. **OnSaveConfigClicked()** - 添加AreaId限制检查 -4. **CreateNewAreaConfig()** - 改为弹窗输入AreaId,添加验证 -5. **ParseAndCreateActionGroups()** - 跳过spine,支持reset_pos -6. **CreateActionGroup()** - 支持reset_pos类型 -7. **UpdateRowActionString()** - 保留spine操作,支持reset_pos -8. **ApplyStepAction()** - 跳过所有spine操作 -9. **ApplyInitAction()** - 跳过init_spine -10. **CreateStepEditItem()** - 添加只读Action显示 - ---- - -## 📝 配置文件格式说明 - -### Action字符串格式 -``` -操作1@操作2@操作3... -``` - -### 支持的操作类型 -| 操作类型 | 格式 | 示例 | UI编辑 | -|---------|------|------|--------| -| clear | `clear#路径1,路径2,...` | `clear#bg/clearObj/3,bg/clearObj/4` | ✅ 可编辑 | -| add | `add#路径1,路径2,...` | `add#bg/addObj/5,bg/addObj/6` | ✅ 可编辑 | -| replace | `replace#旧路径,新路径` | `replace#bg/clearObj/1,bg/addObj/1` | ✅ 可编辑 | -| replace_image | `replace_image#节点路径,图片路径` | `replace_image#bg,BG/s3_bg_2` | ✅ 可编辑 | -| reset_pos | `reset_pos#节点路径,x=y` | `reset_pos#bg/clearObj/2,-156=-838` | ✅ 可编辑 | -| init_spine | `init_spine#...` | - | ❌ 自动保留 | -| replace_spine | `replace_spine#...` | - | ❌ 自动保留 | - -### Spine操作处理策略 -- **读取时**:spine操作不显示在UI中 -- **编辑时**:用户无法看到和修改spine操作 -- **保存时**:spine操作放在Action字符串的最前面,原样保留 -- **预览时**:spine操作不执行(避免spine加载问题) - ---- - -## ⚠️ 注意事项 - -1. **AreaId限制** - - AreaId 1和2不可通过编辑器修改 - - 如需修改,需要直接编辑配置文件或联系编辑器作者 - -2. **步骤数量固定** - - 所有场景固定25步 - - 如需修改步骤数量,需要修改编辑器代码 - -3. **Spine无感知** - - 用户在UI中完全看不到spine相关配置 - - 但spine配置不会丢失,保存时会自动保留 - -4. **新场景创建** - - 创建新场景后,配置仅在内存中,需手动保存 - - 保存前可以预览场景效果 - -5. **reset_pos坐标格式** - - 必须使用 `x=y` 格式(使用等号=分隔) - - 示例:`-156=-838` 或 `100=200` - - 不支持其他分隔符(如逗号或冒号) - -6. **配置完整性** - - 只读Action显示帮助验证配置正确性 - - 建议每次编辑后检查只读显示的内容 - ---- - -## 🐛 已知问题 - -无 - ---- - -## 📞 联系方式 - -如需对编辑器进行调整或遇到问题,请联系编辑器作者(你)。 - ---- - -## 📊 测试检查清单 - -- [ ] 尝试编辑AreaId=1,验证拒绝 -- [ ] 尝试编辑AreaId=2,验证拒绝 -- [ ] 尝试修改步骤数量,验证输入框禁用 -- [ ] 读取不存在的AreaId,验证提示正确 -- [ ] 创建新场景,输入AreaId=1,验证拒绝 -- [ ] 创建新场景,输入AreaId=3,验证成功 -- [ ] 创建新场景,输入已存在的AreaId,验证拒绝 -- [ ] 编辑包含spine的配置,验证spine不显示在UI -- [ ] 保存包含spine的配置,验证spine保留在最前面 -- [ ] 添加reset_pos操作,验证可正常添加和编辑 -- [ ] 预览包含reset_pos的步骤,验证位置正确设置 -- [ ] 编辑操作后,验证只读Action显示实时更新 -- [ ] 新建场景不保存直接关闭,验证配置文件未改变 diff --git a/Assets/Editor/CustomTools/DecorateConfigEditor/CHANGELOG.md.meta b/Assets/Editor/CustomTools/DecorateConfigEditor/CHANGELOG.md.meta deleted file mode 100644 index d7cefed..0000000 --- a/Assets/Editor/CustomTools/DecorateConfigEditor/CHANGELOG.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 0c1336f834fb30c45986701ba8b43f3e -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Editor/CustomTools/DecorateConfigEditor/DecorateConfigEditor.cs b/Assets/Editor/CustomTools/DecorateConfigEditor/DecorateConfigEditor.cs deleted file mode 100644 index 2b3d9d5..0000000 --- a/Assets/Editor/CustomTools/DecorateConfigEditor/DecorateConfigEditor.cs +++ /dev/null @@ -1,4954 +0,0 @@ -using UnityEditor; -using UnityEngine; -using UnityEngine.UIElements; -using UnityEditor.UIElements; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Linq; -using UIButton = UnityEngine.UIElements.Button; -using UIToggle = UnityEngine.UIElements.Toggle; -using UnityEngine.UI; -using Spine.Unity; -using OfficeOpenXml; // EPPlus用于读取Excel -using ArtResource; // 美术资源SO - -/// -/// 装饰配置统一编辑器 -/// 支持读取/保存配置、场景还原、步骤编辑 -/// -public class DecorateConfigEditor : EditorWindow -{ - [MenuItem("蹊径/场景建造工具")] - public static void ShowWindow() - { - DecorateConfigEditor wnd = GetWindow(); - wnd.titleContent = new GUIContent("装饰配置编辑器"); - wnd.minSize = new Vector2(800, 600); - } - // UI控件 - private TextField configPathField; - private IntegerField areaIdField; - private IntegerField stepCountField; - private ObjectField bgObjectField; - private IntegerField currentStepField; - private Label stepInfoLabel; - private VisualElement stepEditContainer; - private ScrollView stepEditScrollView; // 步骤编辑滚动视图 - private Label emptyLabel; - private Label statusLabel; // 状态栏 - private VisualElement configContent; // 配置管理可折叠内容 - private UIButton toggleConfigButton; // 折叠按钮 - private bool isConfigExpanded = true; // 配置区域展开状态 - private VisualElement stepGridContainer; // 步骤网格容器 - private List stepGridButtons = new List(); // 步骤网格按钮列表 - private VisualElement initEditContent; // 初始状态编辑可折叠内容 - private UIButton toggleInitEditButton; // 初始状态编辑折叠按钮 - private bool isInitEditExpanded = true; // 初始状态编辑展开状态 - private VisualElement initEditContainer; // 初始状态编辑容器 - private Label initEmptyLabel; // 初始状态空标签 - - // 数据 - private string configFilePath = "E:\\WorkSpace\\Docs\\config\\DecorateCost.xlsx"; // 修改为XLSX路径 - private const string SHEET_NAME = "DecorateCost"; // Sheet名称 - private Transform bgTransform; - private Transform decoratePanelTransform; // 装饰按钮Panel - private int currentAreaId = 1; - private int currentStepIndex = 0; - private int maxSteps = 25; - - // 配置数据结构 - private List allConfigRows = new List(); - private List currentAreaInitRows = new List(); // sortId=0的初始化行 - private List currentAreaStepRows = new List(); // sortId>0的步骤行 - - // 暂存区和原始数据(用于对比修改) - private List tempAreaInitRows = new List(); // 初始状态暂存区 - private List originalAreaStepRows = new List(); // 原始步骤数据 - private List originalAreaInitRows = new List(); // 原始初始状态数据 - - // 修改状态标记 - private bool isStepsModified = false; // 步骤是否已修改 - private bool isInitRecorded = false; // 初始状态是否已记录 - private bool isNewScene = false; // 是否是新场景 - - // 剪贴板:用于复制/粘贴配置 - private string clipboardAction = ""; // 复制的Action配置 - - // SO资源缓存 - private ArtTableSO decorateIconSO; // 图标资源SO - private Dictionary decorateSceneSODict = new Dictionary(); // 场景资源SO字典(按AreaId缓存) - - public void CreateGUI() - { - VisualElement root = rootVisualElement; - - // 加载UXML - var visualTree = AssetDatabase.LoadAssetAtPath( - "Assets/Editor/CustomTools/DecorateConfigEditor/DecorateConfigEditor.uxml"); - - if (visualTree == null) - { - Debug.LogError("无法加载UXML文件!请检查路径:Assets/Editor/CustomTools/DecorateConfigEditor/DecorateConfigEditor.uxml"); - return; - } - - VisualElement uxml = visualTree.Instantiate(); - root.Add(uxml); - - // 绑定UI控件 - BindUIControls(); - // 绑定事件 - BindEvents(); - - // 初始化折叠按钮状态 - InitializeToggleButtonStates(); - - // 初始化默认配置路径 - if (configPathField != null) - { - configPathField.value = configFilePath; - } - - // 显示分辨率提示 - ShowResolutionWarning(); - - // 自动查找bg节点 - AutoFindBgNode(); - // 自动查找DecoratePanel - AutoFindDecoratePanel(); - } - - /// - /// 初始化折叠按钮的状态,确保UI和代码状态一致 - /// - private void InitializeToggleButtonStates() - { - // 配置区域默认展开 - if (configContent != null && toggleConfigButton != null) - { - configContent.style.display = DisplayStyle.Flex; - toggleConfigButton.text = "▲ 折叠"; - isConfigExpanded = true; - } - - // 初始状态编辑区域默认展开 - if (initEditContent != null && toggleInitEditButton != null) - { - initEditContent.style.display = DisplayStyle.Flex; - toggleInitEditButton.text = "▲ 折叠"; - isInitEditExpanded = true; - } - } - - /// - /// 自动查找场景中的bg节点并设置 - /// - private void AutoFindBgNode() - { - // 尝试查找 Canvas/MainDecoratePanel/ImageBg/bg - GameObject canvas = GameObject.Find("Canvas"); - if (canvas != null) - { - Transform mainDecoratePanel = canvas.transform.Find("MainDecoratePanel"); - if (mainDecoratePanel != null) - { - Transform imageBg = mainDecoratePanel.Find("ImageBg"); - if (imageBg != null) - { - Transform bg = imageBg.Find("bg"); - if (bg != null) - { - bgObjectField.value = bg; - bgTransform = bg; - return; - } - } - } - } - - Debug.Log("未找到默认bg节点路径(Canvas/MainDecoratePanel/ImageBg/bg),请手动拖入"); - } - - /// - /// 自动查找AreaDecoratePanel - /// - private void AutoFindDecoratePanel() - { - GameObject canvas = GameObject.Find("Canvas"); - if (canvas != null) - { - Transform areaDecoratePanel = canvas.transform.Find("AreaDecoratePanel"); - if (areaDecoratePanel != null) - { - decoratePanelTransform = areaDecoratePanel; - // 默认隐藏装饰按钮 - decoratePanelTransform.gameObject.SetActive(false); - return; - } - } - - Debug.Log("未找到AreaDecoratePanel,装饰按钮显示功能将无法使用"); - } - - private void BindUIControls() - { - configPathField = rootVisualElement.Q("ConfigPathField"); - areaIdField = rootVisualElement.Q("AreaIdField"); - stepCountField = rootVisualElement.Q("StepCountField"); - if (stepCountField != null) - { - stepCountField.SetEnabled(false); // 禁用步骤数量编辑 - } - bgObjectField = rootVisualElement.Q("BgObjectField"); - currentStepField = rootVisualElement.Q("CurrentStepField"); - stepInfoLabel = rootVisualElement.Q