/// <summary> /// 合并列 /// </summary> /// <param name="row"></param> /// <param name="startCloumn"></param> /// <param name="endCloumn"></param> public void MergeCloumn(int row, int startCloumn, int endCloumn) { ////获取到这个范围内的所有列,判断是否存在已经隐藏的,如果存在,则直接跳过 //for (int i = startCloumn; i < endCloumn; i++) //{ // if (Rows[row].Cells[i].IsHide) return;//如果存在隐藏的,则直接跳过。表示所选的已经有合并了 //} KGUI_TableCell startCell = GetTableCell(new Vector2Int(row, startCloumn)); //判断起始单元格,是否还存在其他的行 int _row; if (startCell.IsExistRow(out _row)) { for (int i = row + 1; i <= _row; i++) { //将该行的所有列都注释掉 for (int j = startCloumn; j <= endCloumn; j++) { startCell.AddCell(GetTableCell(new Vector2Int(i, j))); } } } //如果存在,则也将其他的行包含过去,执行合并单元格 for (int i = startCloumn + 1; i <= endCloumn; i++) { //合并列 startCell.OnCloumMerge(GetTableCell(new Vector2Int(row, i)), spacing); } }
/// <summary> /// 合并行 /// </summary> /// <param name="cloumn"></param> /// <param name="startRow"></param> /// <param name="endRow"></param> public void MergeRow(int cloumn, int startRow, int endRow) { //获取到这个范围内的所有列,判断是否存在已经隐藏的,如果存在,则直接跳过 for (int i = startRow; i < startRow; i++) { //如果存在隐藏的,则直接跳过。表示所选的已经有合并了 if (Rows[i].Cells[cloumn].IsHide) { Debug.Log("已经存在合并的"); return; } ; } KGUI_TableCell startCell = GetTableCell(new Vector2Int(startRow, cloumn)); int _cloumn; if (startCell.IsExistRow(out _cloumn)) { for (int i = cloumn + 1; i <= _cloumn; i++) { //将该列的所有行都注释掉 for (int j = startRow; j <= endRow; j++) { startCell.AddCell(GetTableCell(new Vector2Int(j, i))); } } } //如果存在,则也将其他的行包含过去,执行合并单元格 for (int i = startRow + 1; i <= endRow; i++) { //合并列 startCell.OnRowMerge(GetTableCell(new Vector2Int(i, cloumn)), spacing); } }