///// <summary> ///// 合并 ///// </summary> ///// <param name="cell"></param> //public void OnMerge(KGUI_TableCell cell, float spaceing) //{ // //是否行相邻 // OnRowMerge(cell, spaceing); // //是否列相邻 // OnCloumMerge(cell, spaceing); //} ///// <summary> ///// 是否行相邻 ///// </summary> ///// <param name="cell"></param> ///// <returns></returns> //public bool OnRowNeighbor(KGUI_TableCell cell) //{ // //如果数组的最后一个,不跟他相邻的话,则直接跳过 // float row = 0; // foreach (var item in Cells) // { // //找到最大的行值 // if (item.Position.x > row) // row = item.Position.x; // } // //判断是否相邻 // if (Mathf.Abs(cell.Position.x - row) != 1 || Mathf.Abs(cell.Position.x - Position.x) != 1) return false; // return true; //} //public bool OnCloumNeighbor(KGUI_TableCell cell) //{ // //if (cell.Position.y - Position.y != 1) return false; // float cloum = 0; // foreach (var item in Cells) // { // if (item.Position.y > cloum) // cloum = item.Position.y; // } // //不相邻,则直接跳过 // if (Mathf.Abs(cell.Position.y - cloum) != 1 || cell.Position.y - Position.y != 1) return false; // return true; //} #endregion /// <summary> /// 行合并 /// </summary> /// <param name="cell"></param> /// <param name="spaceing"></param> /// <returns></returns> public bool OnRowMerge(KGUI_TableCell cell, float spaceing) { ////如果不在同一列的话,则直接跳过 //if (Position.y != cell.Position.y|| !OnRowNeighbor(cell)) // //判断是否行相邻 // return false; //如果不相邻,则跳过 //if (!OnRowNeighbor(cell)) return false; if (cell == null) { return(false); } if (!Cells.Contains(cell)) { //进行合并 Cells.Add(cell); cell.OnHide(); } //重新计算高度 Size = new Vector2(Size.x, cell.Size.y + Size.y + spaceing); return(true); }
/// <summary> /// 添加单元格 /// </summary> /// <param name="cell"></param> public void AddCell(KGUI_TableCell cell) { if (!Cells.Contains(cell)) { Cells.Add(cell); cell.OnHide(); } }
/// <summary> /// 列合并 /// </summary> /// <param name="cell"></param> /// <param name="spaceing"></param> /// <returns></returns> public bool OnCloumMerge(KGUI_TableCell cell, float spaceing) { if (cell == null) { return(false); } if (!Cells.Contains(cell)) { Cells.Add(cell); cell.OnHide(); } Size = new Vector2(cell.Size.x + Size.x + spaceing, Size.y); return(true); }