public void UpdateTable() { var updater = m_TableDisplay.BeginUpdate(); if (updater != null) { long sel = updater.OldToNewRow(m_GUIState.SelectedRow); //find the row that is still the first visible or the previous one that still exist after the uptate long fvr = -1; long fvr_before = m_GUIState.FirstVisibleRow; do { fvr = updater.OldToNewRow(fvr_before); --fvr_before; }while (fvr < 0 && fvr_before >= 0); //if did not find any valid first visible row, use selected row if (fvr < 0) { fvr = sel; } m_TableSource.EndUpdate(updater); if (fvr >= 0) { long nextRow; long fvrIndex = 0; float fvrY = GetCumulativeHeight(GetFirstRow(), fvr, out nextRow, ref fvrIndex); long lastIndex = fvrIndex; float totalh = fvrY + GetCumulativeHeight(nextRow, long.MaxValue, out nextRow, ref lastIndex); m_GUIState.ScrollPosition.y = fvrY; m_GUIState.FirstVisibleRowY = fvrY; m_GUIState.FirstVisibleRow = fvr; m_GUIState.FirstVisibleRowIndex = fvrIndex; m_GUIState.HeightBeforeFirstVisibleRow = fvrY; m_DataState.TotalDataHeight = totalh; } else { m_GUIState.ScrollPosition = Vector2.zero; m_GUIState.FirstVisibleRowY = 0; m_GUIState.FirstVisibleRow = GetFirstRow(); m_GUIState.FirstVisibleRowIndex = 0; m_GUIState.HeightBeforeFirstVisibleRow = 0; long nextRow; long lastIndex = 0; m_DataState.TotalDataHeight = GetCumulativeHeight(GetFirstRow(), long.MaxValue, out nextRow, ref lastIndex); } m_GUIState.SelectedRow = sel; //m_Listener.OnRepaint(); } else { m_TableDisplay.EndUpdate(updater); } //UpdateDataState(); //ResetGUIState(); }