Unity-Technologies/UnityCsReference · error · NotSupportedException
Only call this method if you are using a MultiColumnHeader w
Error message
Only call this method if you are using a MultiColumnHeader with the TreeView.
What it means
Thrown by RowGUIArgs.GetNumVisibleColumns when the TreeView is not using a MultiColumnHeader (HasMultiColumnInfo returns false). The method returns the count of visible columns from the column info struct, which only exists when the TreeView was constructed with a MultiColumnHeader.
Source
Thrown at Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs:871
}
}
// Nested because they are used by protected methods
protected internal struct RowGUIArgs
{
public TreeViewItem<TIdentifier> item;
public string label;
public Rect rowRect;
public int row;
public bool selected;
public bool focused;
public bool isRenaming;
internal MultiColumnInfo columnInfo { get; set; }
public int GetNumVisibleColumns()
{
if (!HasMultiColumnInfo())
throw new NotSupportedException("Only call this method if you are using a MultiColumnHeader with the TreeView.");
return columnInfo.multiColumnHeaderState.visibleColumns.Length;
}
public int GetColumn(int visibleColumnIndex)
{
if (!HasMultiColumnInfo())
throw new NotSupportedException("Only call this method if you are using a MultiColumnHeader with the TreeView.");
return columnInfo.multiColumnHeaderState.visibleColumns[visibleColumnIndex];
}
public Rect GetCellRect(int visibleColumnIndex)
{
if (!HasMultiColumnInfo())
throw new NotSupportedException("Only call this method if you are using a MultiColumnHeader with the TreeView.");
return columnInfo.cellRects[visibleColumnIndex];View on GitHub (pinned to 225b0fbdb5)
Solutions
- Guard with args.HasMultiColumnInfo() before calling GetNumVisibleColumns().
- Branch RowGUI logic based on whether a MultiColumnHeader is present.
- Use the MultiColumnHeader TreeView constructor if column iteration is needed.
Example fix
// before
for (int i = 0; i < args.GetNumVisibleColumns(); i++) { ... }
// after
if (!args.HasMultiColumnInfo()) { base.RowGUI(args); return; }
for (int i = 0; i < args.GetNumVisibleColumns(); i++) { ... } Defensive patterns
Strategy: type-guard
Validate before calling
if (args.HasMultiColumnInfo())
{
for (int i = 0; i < args.GetNumVisibleColumns(); i++) { ... }
} Type guard
// HasMultiColumnInfo() is the built-in guard on RowGUIArgs bool safe = args.HasMultiColumnInfo();
Prevention
- Always check HasMultiColumnInfo() before column-related RowGUIArgs calls.
- Branch RowGUI for single- vs multi-column modes.
- Do not reuse multi-column draw code unconditionally.
When it happens
Trigger: Calling args.GetNumVisibleColumns() inside RowGUI on a single-column TreeView; calling before columnInfo was set; using shared RowGUI code across both single- and multi-column TreeView subclasses.
Common situations: Overriding RowGUI and unconditionally iterating visible columns; code copied from a multi-column example into a single-column TreeView.
Related errors
- visibleColumns should should not be set to an empty array. A
- Setting columnIndexForTreeFoldouts can only be set when usin
- Invalid index for columnIndexForTreeFoldouts: {0}. Number of
- GetCellRect can only be called when 'multiColumnHeader' has
- Invalid list: cannot be null
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/3a463eb9ca7b2055.
Report an issue: GitHub.