Unity-Technologies/UnityCsReference · error · ArgumentException
Invalid columnIndex: {0}. The index is not part of the curre
Error message
Invalid columnIndex: {0}. The index is not part of the current visible columns: {1} What it means
Thrown by GetVisibleColumnIndex when the requested columnIndex is not present in state.visibleColumns. It only accepts columns currently marked visible; hidden columns have no visible-position mapping.
Source
Thrown at Editor/Mono/GUI/TreeView/MultiColumnHeader.cs:168
public bool IsColumnVisible(int columnIndex)
{
foreach (int vc in state.visibleColumns)
{
if (vc == columnIndex)
return true;
}
return false;
}
public int GetVisibleColumnIndex(int columnIndex)
{
for (int i = 0; i < state.visibleColumns.Length; i++)
{
if (state.visibleColumns[i] == columnIndex)
return i;
}
string visibleIndices = string.Join(", ", state.visibleColumns);
throw new ArgumentException(string.Format("Invalid columnIndex: {0}. The index is not part of the current visible columns: {1}", columnIndex, visibleIndices), "columnIndex");
}
public Rect GetCellRect(int visibleColumnIndex, Rect rowRect)
{
Rect result = GetColumnRect(visibleColumnIndex);
result.y = rowRect.y;
result.height = rowRect.height;
return result;
}
public Rect GetColumnRect(int visibleColumnIndex)
{
if (visibleColumnIndex < 0 || visibleColumnIndex >= m_ColumnRects.Length)
throw new ArgumentException(string.Format("The provided visibleColumnIndex is invalid. Ensure the index ({0}) is within the number of visible columns ({1})", visibleColumnIndex, m_ColumnRects.Length), "visibleColumnIndex");
return m_ColumnRects[visibleColumnIndex];
}
View on GitHub (pinned to 225b0fbdb5)
Solutions
- Check IsColumnVisible(columnIndex) before calling GetVisibleColumnIndex.
- Rebuild cached indices whenever visibleColumns changes.
- Hide/show the column first if the operation requires it to be visible.
Example fix
// before int vIdx = header.GetVisibleColumnIndex(colIdx); // after if (!header.IsColumnVisible(colIdx)) return -1; int vIdx = header.GetVisibleColumnIndex(colIdx);
Defensive patterns
Strategy: validation
Validate before calling
if (!header.IsColumnVisible(columnIndex)) return -1; return header.GetVisibleColumnIndex(columnIndex);
Type guard
static bool IsVisibleColumn(int i, MultiColumnHeader h) => h.IsColumnVisible(i);
Prevention
- Call IsColumnVisible before GetVisibleColumnIndex.
- Invalidate cached visible indices when visibility changes.
- Treat hidden columns explicitly in your layout logic.
When it happens
Trigger: Passing a columnIndex for a column the user has hidden; querying a visible position for an always-hidden column.
Common situations: User toggled column visibility after an index was cached; a layout referencing a column that was removed from the visible set.
Related errors
- MultiColumnHeader state is not allowed to be null
- columnIndices
- sortAscending
- Input arrays should have same length
- The maximum number of sorted columns is {state.maximumNumber
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/3e40c3aac08d67b7.
Report an issue: GitHub.