修复表格每次选中单元格会导致线框切换一次渲染状态的问题。
修复表格移动超过三个单元格会突然全部隐藏的问题。
This commit is contained in:
@@ -215,6 +215,8 @@ namespace XericUI.XTable.Rendering.Component
|
|||||||
{
|
{
|
||||||
// 跳过被合并覆盖的单元格
|
// 跳过被合并覆盖的单元格
|
||||||
if (TableData.IsCellMerged(row, col)) continue;
|
if (TableData.IsCellMerged(row, col)) continue;
|
||||||
|
// 跳过不可见的单元格
|
||||||
|
if (!IsCellVisible(row, col)) continue;
|
||||||
|
|
||||||
float cellX = GetColLeftX(col);
|
float cellX = GetColLeftX(col);
|
||||||
float cellY = -GetRowTopY(row);
|
float cellY = -GetRowTopY(row);
|
||||||
@@ -315,6 +317,8 @@ namespace XericUI.XTable.Rendering.Component
|
|||||||
{
|
{
|
||||||
// 跳过被合并覆盖的单元格
|
// 跳过被合并覆盖的单元格
|
||||||
if (TableData.IsCellMerged(row, col)) continue;
|
if (TableData.IsCellMerged(row, col)) continue;
|
||||||
|
// 跳过不可见的单元格
|
||||||
|
if (!IsCellVisible(row, col)) continue;
|
||||||
|
|
||||||
float cellX = GetColLeftX(col);
|
float cellX = GetColLeftX(col);
|
||||||
float cellY = -GetRowTopY(row);
|
float cellY = -GetRowTopY(row);
|
||||||
@@ -932,6 +936,11 @@ namespace XericUI.XTable.Rendering.Component
|
|||||||
RecalculateTotalSize();
|
RecalculateTotalSize();
|
||||||
UpdateVisibleRect();
|
UpdateVisibleRect();
|
||||||
|
|
||||||
|
// 确保 ScrollRect Content 尺寸正确(否则滚动时可能裁剪掉全部内容)
|
||||||
|
RectTransform ctRt = ContentTransform as RectTransform;
|
||||||
|
if (ctRt != null)
|
||||||
|
ctRt.sizeDelta = new Vector2(m_TotalWidth, m_TotalHeight);
|
||||||
|
|
||||||
// 更新背景尺寸
|
// 更新背景尺寸
|
||||||
if (m_BackgroundGo != null)
|
if (m_BackgroundGo != null)
|
||||||
{
|
{
|
||||||
@@ -960,12 +969,14 @@ namespace XericUI.XTable.Rendering.Component
|
|||||||
Transform poolRoot = m_Assembler.PoolRoot;
|
Transform poolRoot = m_Assembler.PoolRoot;
|
||||||
Transform prefabPoolRoot = m_PrefabPool?.PoolRoot;
|
Transform prefabPoolRoot = m_PrefabPool?.PoolRoot;
|
||||||
Transform contentT = ContentTransform;
|
Transform contentT = ContentTransform;
|
||||||
|
Transform borderT = contentT.Find("_TableBorders");
|
||||||
for (int i = contentT.childCount - 1; i >= 0; i--)
|
for (int i = contentT.childCount - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
var child = contentT.GetChild(i);
|
var child = contentT.GetChild(i);
|
||||||
if (poolRoot != null && child == poolRoot) continue;
|
if (poolRoot != null && child == poolRoot) continue;
|
||||||
if (prefabPoolRoot != null && child == prefabPoolRoot) continue;
|
if (prefabPoolRoot != null && child == prefabPoolRoot) continue;
|
||||||
if (m_BackgroundGo != null && child.gameObject == m_BackgroundGo) continue;
|
if (m_BackgroundGo != null && child.gameObject == m_BackgroundGo) continue;
|
||||||
|
if (borderT != null && child == borderT) continue;
|
||||||
|
|
||||||
child.gameObject.hideFlags = HideFlags.None;
|
child.gameObject.hideFlags = HideFlags.None;
|
||||||
if (Application.isPlaying)
|
if (Application.isPlaying)
|
||||||
@@ -1434,6 +1445,18 @@ namespace XericUI.XTable.Rendering.Component
|
|||||||
|
|
||||||
#region 坐标计算
|
#region 坐标计算
|
||||||
|
|
||||||
|
/// <summary>判断指定单元格是否与当前可见矩形有重叠(用于 RenderQuadrants 裁剪)</summary>
|
||||||
|
private bool IsCellVisible(int row, int col)
|
||||||
|
{
|
||||||
|
float cellTop = GetRowTopY(row);
|
||||||
|
float cellBottom = cellTop + m_RowHeights[row];
|
||||||
|
float cellLeft = GetColLeftX(col);
|
||||||
|
float cellRight = cellLeft + m_ColWidths[col];
|
||||||
|
|
||||||
|
return cellBottom > m_VisibleRect.y && cellTop < m_VisibleRect.yMax &&
|
||||||
|
cellRight > m_VisibleRect.x && cellLeft < m_VisibleRect.xMax;
|
||||||
|
}
|
||||||
|
|
||||||
private float GetRowTopY(int row)
|
private float GetRowTopY(int row)
|
||||||
{
|
{
|
||||||
float y = 0;
|
float y = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user