private void SetDynamicPosition(IParamData paramData, int gridIndex, int lineIndex, float space) { if (m_moveType == UIScrollView.Movement.Horizontal) { if (paramData == null) { transform.localPosition = new Vector3(m_grid.cellWidth * gridIndex + space, -m_grid.cellHeight * lineIndex, 0); } else { float totalCellWidth = paramData.GetPosx(); if (totalCellWidth <= 0) { if (m_index == 0) { totalCellWidth = 0; } else { totalCellWidth = (m_datas[m_index - 1] as IParamData).GetPosx() + (m_datas[m_index - 1] as IParamData).GetWidth() + space; } } paramData.SetPosx(totalCellWidth); transform.localPosition = new Vector3(totalCellWidth, -m_grid.cellHeight * lineIndex, 0); } } else if (m_moveType == UIScrollView.Movement.Vertical) { if (paramData == null) { transform.localPosition = new Vector3(m_grid.cellWidth * lineIndex, -m_grid.cellHeight * gridIndex - space, 0); } else { float totalCellHeight = paramData.GetPosy(); if (totalCellHeight <= 0) { if (m_index == 0) { totalCellHeight = 0; } else { totalCellHeight = (m_datas[m_index - 1] as IParamData).GetPosy() + (m_datas[m_index - 1] as IParamData).GetHeight() - space; } } else { totalCellHeight = (m_datas[m_index - 1] as IParamData).GetPosy() + (m_datas[m_index - 1] as IParamData).GetHeight() - space; } paramData.SetPosy(totalCellHeight); transform.localPosition = new Vector3(m_grid.cellWidth * lineIndex, -totalCellHeight - space, 0); } } }
protected virtual void ChangeDynamicPosition(IParamData paramData, int gridIndex, int lineIndex, float space, bool autoRefreshData = true, bool resetFront = false) { if (m_moveType == UIScrollView.Movement.Horizontal) { if (resetFront) { for (int i = 0; i < m_datas.Count; i++) { //if(i< m_index + 1) //{ // IParamData now = m_datas[i] as IParamData; // now.SetPosx(0); //} //else //{ // IParamData now = m_datas[i] as IParamData; // IParamData front = m_datas[i - 1] as IParamData; // now.SetPosx(front.GetPosx() + front.GetWidth()); //} IParamData now = m_datas[i] as IParamData; if (i < m_index) { now.Reset(); } if (i >= 1) { IParamData front = m_datas[i - 1] as IParamData; now.SetPosx(front.GetPosx() + front.GetWidth()); } } } else { for (int i = m_index + 1; i < m_datas.Count; i++) { IParamData now = m_datas[i] as IParamData; IParamData front = m_datas[i - 1] as IParamData; now.SetPosx(front.GetPosx() + front.GetWidth()); } } } else if (m_moveType == UIScrollView.Movement.Vertical) { if (resetFront) { for (int i = 0; i < m_datas.Count; i++) { //if (i < m_index + 1) //{ // IParamData now = m_datas[i] as IParamData; // now.SetPosy(0); //} //else //{ // IParamData now = m_datas[i] as IParamData; // IParamData front = m_datas[i - 1] as IParamData; // now.SetPosy(front.GetPosy() + front.GetHeight()); //} IParamData now = m_datas[i] as IParamData; if (i < m_index) { now.Reset(); } if (i >= 1) { IParamData front = m_datas[i - 1] as IParamData; now.SetPosy(front.GetPosy() + front.GetHeight()); } } } else { for (int i = m_index + 1; i < m_datas.Count; i++) { IParamData now = m_datas[i] as IParamData; IParamData front = m_datas[i - 1] as IParamData; now.SetPosy(front.GetPosy() + front.GetHeight()); } } } if (autoRefreshData) { grid.RefreshData(); } }