修复bug

This commit is contained in:
zhang hongbo 2026-05-13 16:49:19 +08:00
parent 2f71c7e027
commit d3e1c67043

View File

@ -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<RectTransform>();
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<RectTransform>();
if (rt != null)
{