From d3e1c670432b6c54bbff3f3d5f2cd55e16f8eca2 Mon Sep 17 00:00:00 2001 From: zhang hongbo Date: Wed, 13 May 2026 16:49:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DecorateConfig/DecorateConfigEditor.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Editor/Art_Tools/DecorateConfig/DecorateConfigEditor.cs b/Editor/Art_Tools/DecorateConfig/DecorateConfigEditor.cs index ec65a332..6a50fd55 100644 --- a/Editor/Art_Tools/DecorateConfig/DecorateConfigEditor.cs +++ b/Editor/Art_Tools/DecorateConfig/DecorateConfigEditor.cs @@ -1915,13 +1915,15 @@ public partial class DecorateConfigEditor : EditorWindow if (target != bgTransform) { // 设置位置 - if (!string.IsNullOrEmpty(row.Pos) && row.Pos != "0#0") + // 注意:不能因为 Pos == "0#0" 就跳过写入,否则上一个场景遗留在 RectTransform 上的坐标会保留下来 + // (之前的 bug:场景 38 加载后 addObj/1 Y=非零,切到 Pos="0#0" 的场景 37 时 Y 没被重置为 0) + if (!string.IsNullOrEmpty(row.Pos)) { string[] posArr = row.Pos.Split('#'); - if (posArr.Length == 2) + if (posArr.Length == 2 + && int.TryParse(posArr[0], out int x) + && int.TryParse(posArr[1], out int y)) { - int x = int.Parse(posArr[0]); - int y = int.Parse(posArr[1]); RectTransform rt = target.GetComponent(); if (rt != null) { @@ -1934,10 +1936,10 @@ public partial class DecorateConfigEditor : EditorWindow if (!string.IsNullOrEmpty(row.Origin)) { string[] sizeArr = row.Origin.Split('#'); - if (sizeArr.Length == 2) + if (sizeArr.Length == 2 + && int.TryParse(sizeArr[0], out int w) + && int.TryParse(sizeArr[1], out int h)) { - int w = int.Parse(sizeArr[0]); - int h = int.Parse(sizeArr[1]); RectTransform rt = target.GetComponent(); if (rt != null) {