表格:背景/边框的图元原点按"rect 中心"摆放;调试开关覆盖整棵生成层级
坐标错位的真正来源在图元渲染器的上游:PrimitiveCacheRendererBase / CacheLineRendererBase 把 子块建成"铺满本渲染器、轴心 0.5"的对象,顶点直接放在子块本地空间 ⇒ 图元坐标的原点是 rect 的<b>中心</b>,不是左上角。表格喂的是左上角坐标,于是背景与边框(两者都是图元渲染器) 一起偏了半个尺寸、彼此严丝合缝,却和文本(UGUI 左上角语义)对不上。 - 新增 PinPrimitiveRect:锚点 (0,1)、轴心 0.5、锚位放在左上角 ⇒ rect 中心(即网格原点) 与左上角重合;背景、边框、冻结边框都改走它,绘图代码保持左上角语义不变。 - 撤回上一版按 rectTransform.rect 换算原点的做法(那个假设是错的)。 - SetChildrenVisible 改为遍历整棵生成层级(模板/背景/边框/冻结层/池化单元格), 显示时只去掉 HideInHierarchy、保留 NotEditable:调试视图能看到每一个生成物。
This commit is contained in:
@@ -104,21 +104,34 @@ namespace XericUI.XTable.Rendering.Component
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>设置所有动态子对象的可见性(仅编辑器)</summary>
|
||||
/// <summary>
|
||||
/// 设置所有动态子对象的可见性(仅编辑器)。覆盖整棵生成层级:模板(Viewport/Content/
|
||||
/// 滚动条)、背景、边框、冻结层、池化单元格都挂 DontSave,这里统一把 HideInHierarchy 去掉。
|
||||
/// </summary>
|
||||
public void SetChildrenVisible(bool visible)
|
||||
{
|
||||
m_ChildrenVisible = visible;
|
||||
#if UNITY_EDITOR
|
||||
Transform t = ContentTransform;
|
||||
if (t == null) return;
|
||||
for (int i = t.childCount - 1; i >= 0; i--)
|
||||
{
|
||||
var child = t.GetChild(i);
|
||||
child.gameObject.hideFlags = visible
|
||||
? HideFlags.DontSave
|
||||
: HideFlags.DontSave | HideFlags.HideInHierarchy;
|
||||
}
|
||||
ApplyGeneratedVisibility(transform, visible);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private static void ApplyGeneratedVisibility(Transform parent, bool visible)
|
||||
{
|
||||
for (int i = 0; i < parent.childCount; i++)
|
||||
{
|
||||
var child = parent.GetChild(i);
|
||||
if ((child.gameObject.hideFlags & HideFlags.DontSave) != 0)
|
||||
{
|
||||
// NotEditable 保留:看得见、不误改(编辑期改动不会被记成预制体覆盖)。
|
||||
child.gameObject.hideFlags = visible
|
||||
? HideFlags.DontSave | HideFlags.NotEditable
|
||||
: HideFlags.DontSave | HideFlags.NotEditable | HideFlags.HideInHierarchy;
|
||||
}
|
||||
ApplyGeneratedVisibility(child, visible);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user