{"record":{"id":"6c3dc3e5540bc426","repo":"Unity-Technologies/UnityCsReference","slug":"the-provided-visiblecolumnindex-is-invalid-ensure","errorCode":null,"errorMessage":"The provided visibleColumnIndex is invalid. Ensure the index ({0}) is within the number of visible columns ({1})","messagePattern":"The provided visibleColumnIndex is invalid\\. Ensure the index \\((.+?)\\) is within the number of visible columns \\((.+?)\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/GUI/TreeView/MultiColumnHeader.cs","lineNumber":182,"sourceCode":"                if (state.visibleColumns[i] == columnIndex)\n                    return i;\n            }\n            string visibleIndices = string.Join(\", \", state.visibleColumns);\n            throw new ArgumentException(string.Format(\"Invalid columnIndex: {0}. The index is not part of the current visible columns: {1}\", columnIndex, visibleIndices), \"columnIndex\");\n        }\n\n        public Rect GetCellRect(int visibleColumnIndex, Rect rowRect)\n        {\n            Rect result = GetColumnRect(visibleColumnIndex);\n            result.y = rowRect.y;\n            result.height = rowRect.height;\n            return result;\n        }\n\n        public Rect GetColumnRect(int visibleColumnIndex)\n        {\n            if (visibleColumnIndex < 0 || visibleColumnIndex >= m_ColumnRects.Length)\n                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\");\n\n            return m_ColumnRects[visibleColumnIndex];\n        }\n\n        public void ResizeToFit()\n        {\n            m_ResizeToFit = true;\n            Repaint();\n        }\n\n        void UpdateColumnHeaderRects(Rect totalHeaderRect)\n        {\n            if (m_ColumnRects == null || m_ColumnRects.Length != state.visibleColumns.Length)\n                m_ColumnRects = new Rect[state.visibleColumns.Length];\n\n            Rect curRect = totalHeaderRect;\n            for (int v = 0; v < state.visibleColumns.Length; v++)\n            {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/GUI/TreeView/MultiColumnHeader.cs#L164-L200","documentation":"Thrown by GetColumnRect when visibleColumnIndex is negative or >= m_ColumnRects.Length. The cached rectangle array is sized to the visible columns, so an out-of-range index has no geometry to return.","triggerScenarios":"Using an absolute column index where a visible-position (0..visibleCount-1) index is required; calling before the header rects have been laid out (empty m_ColumnRects).","commonSituations":"Confusing the two index spaces; querying rects during initial layout before UpdateColumnHeaderRects has populated the cache.","solutions":["Convert to a visible index via GetVisibleColumnIndex and ensure it is within [0, visibleColumns.Length).","Defer rect queries until after the first layout pass / Repaint.","Guard against m_ColumnRects being empty (early return)."],"exampleFix":"// before\nvar r = header.GetColumnRect(absoluteIdx);\n\n// after\nint vIdx = header.GetVisibleColumnIndex(absoluteIdx);\nif (vIdx >= 0 && vIdx < header.state.visibleColumns.Length)\n    var r = header.GetColumnRect(vIdx);","handlingStrategy":"validation","validationCode":"if (visibleColumnIndex < 0 || visibleColumnIndex >= header.state.visibleColumns.Length) return Rect.zero;","typeGuard":"static bool IsValidVisibleIndex(int i, MultiColumnHeader h) => i >= 0 && i < h.state.visibleColumns.Length;","tryCatchPattern":null,"preventionTips":["Convert absolute indices to visible indices before querying rects.","Defer rect queries until after the first layout pass.","Check m_ColumnRects availability (post-layout) before reading."],"tags":["unity-editor","treeview","multicolumn","bounds-check"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}