From 3603f78d31b3d82ea6a53ef36c9508cb3f36dc6d Mon Sep 17 00:00:00 2001 From: lrc <571244399@qq.com> Date: Thu, 3 Dec 2026 11:27:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=EF=BC=9A=E6=8E=A5=E7=AE=A1?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=9D=A1=E6=97=B6=E4=B8=8D=E6=8A=8A=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=89=8B=E6=91=86=E7=9A=84=E5=AF=B9=E8=B1=A1=E6=A0=87?= =?UTF-8?q?=E6=88=90=E4=B8=8D=E4=BF=9D=E5=AD=98=EF=BC=8C=E4=B9=9F=E4=B8=8D?= =?UTF-8?q?=E9=94=80=E6=AF=81=E5=AE=83=E4=BB=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 只认"我们新建的"或本来就 DontSave 的滚动条:用户自己绑的滚动条照常套样式, 但不打灰色标记、销毁组件时不收走——避免下次保存预制体把它们抹掉。 --- .../Rendering/Component/XTableScrollbarFactory.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Runtime/XTable/Rendering/Component/XTableScrollbarFactory.cs b/Runtime/XTable/Rendering/Component/XTableScrollbarFactory.cs index 2ad9b3c..8e1d9fc 100644 --- a/Runtime/XTable/Rendering/Component/XTableScrollbarFactory.cs +++ b/Runtime/XTable/Rendering/Component/XTableScrollbarFactory.cs @@ -33,6 +33,7 @@ namespace XericUI.XTable.Rendering.Component Scrollbar bar = horizontal ? sr.horizontalScrollbar : sr.verticalScrollbar; string barName = horizontal ? HorizontalName : VerticalName; + bool created = false; if (bar == null) { Transform found = parent.Find(barName); @@ -51,6 +52,7 @@ namespace XericUI.XTable.Rendering.Component bar.handleRect = (RectTransform)handle.transform; bar.transform.SetParent(parent, false); + created = true; Debug.Log("[XTable] 补 " + barName + ":" + parent.name); } @@ -59,7 +61,9 @@ namespace XericUI.XTable.Rendering.Component if (horizontal) sr.horizontalScrollbar = bar; else sr.verticalScrollbar = bar; - MarkGenerated(bar.gameObject); + // 只接管"我们生成的"或本来就 DontSave 的对象;用户手摆的滚动条不标不保存,免得下次保存时被抹掉。 + if (created || (bar.gameObject.hideFlags & HideFlags.DontSave) != 0) + MarkGenerated(bar.gameObject); return bar; } @@ -165,6 +169,10 @@ namespace XericUI.XTable.Rendering.Component internal static void DestroyGenerated(Object target) { if (target == null) return; + GameObject go = target as GameObject; + if (go == null && target is UnityEngine.Component component) go = component.gameObject; + // 只销毁生成物;用户自己的(没有 DontSave)一律不碰。 + if (go == null || (go.hideFlags & HideFlags.DontSave) == 0) return; #if UNITY_EDITOR // 预制体实例里的对象不许立即销毁;它们本来就不保存,重载后自然不在。 if (!Application.isPlaying && UnityEditor.PrefabUtility.IsPartOfPrefabInstance(target))