{"record":{"id":"3a463eb9ca7b2055","repo":"Unity-Technologies/UnityCsReference","slug":"only-call-this-method-if-you-are-using-a-multicolu","errorCode":null,"errorMessage":"Only call this method if you are using a MultiColumnHeader with the TreeView.","messagePattern":"Only call this method if you are using a MultiColumnHeader with the TreeView\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs","lineNumber":871,"sourceCode":"            }\n        }\n\n        // Nested because they are used by protected methods\n        protected internal struct RowGUIArgs\n        {\n            public TreeViewItem<TIdentifier> item;\n            public string label;\n            public Rect rowRect;\n            public int row;\n            public bool selected;\n            public bool focused;\n            public bool isRenaming;\n            internal MultiColumnInfo columnInfo { get; set; }\n\n            public int GetNumVisibleColumns()\n            {\n                if (!HasMultiColumnInfo())\n                    throw new NotSupportedException(\"Only call this method if you are using a MultiColumnHeader with the TreeView.\");\n\n                return columnInfo.multiColumnHeaderState.visibleColumns.Length;\n            }\n\n            public int GetColumn(int visibleColumnIndex)\n            {\n                if (!HasMultiColumnInfo())\n                    throw new NotSupportedException(\"Only call this method if you are using a MultiColumnHeader with the TreeView.\");\n\n                return columnInfo.multiColumnHeaderState.visibleColumns[visibleColumnIndex];\n            }\n\n            public Rect GetCellRect(int visibleColumnIndex)\n            {\n                if (!HasMultiColumnInfo())\n                    throw new NotSupportedException(\"Only call this method if you are using a MultiColumnHeader with the TreeView.\");\n\n                return columnInfo.cellRects[visibleColumnIndex];","sourceCodeStart":853,"sourceCodeEnd":889,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs#L853-L889","documentation":"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.","triggerScenarios":"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.","commonSituations":"Overriding RowGUI and unconditionally iterating visible columns; code copied from a multi-column example into a single-column TreeView.","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."],"exampleFix":"// before\nfor (int i = 0; i < args.GetNumVisibleColumns(); i++) { ... }\n\n// after\nif (!args.HasMultiColumnInfo()) { base.RowGUI(args); return; }\nfor (int i = 0; i < args.GetNumVisibleColumns(); i++) { ... }","handlingStrategy":"type-guard","validationCode":"if (args.HasMultiColumnInfo())\n{\n    for (int i = 0; i < args.GetNumVisibleColumns(); i++) { ... }\n}","typeGuard":"// HasMultiColumnInfo() is the built-in guard on RowGUIArgs\nbool safe = args.HasMultiColumnInfo();","tryCatchPattern":null,"preventionTips":["Always check HasMultiColumnInfo() before column-related RowGUIArgs calls.","Branch RowGUI for single- vs multi-column modes.","Do not reuse multi-column draw code unconditionally."],"tags":["unity","treeview","rowgui","multicolumnheader","not-supported"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}