{"record":{"id":"80086f0b989a2228","repo":"Unity-Technologies/UnityCsReference","slug":"only-call-refreshcustomrowheights-if-you-have-over","errorCode":null,"errorMessage":"Only call RefreshCustomRowHeights if you have overridden GetCustomRowHeight to customize the height of each row.","messagePattern":"Only call RefreshCustomRowHeights if you have overridden GetCustomRowHeight to customize the height of each row\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs","lineNumber":696,"sourceCode":"        internal virtual void RowGUIInternal(RowGUIArgs args)\n        {\n            m_GUI.DefaultRowGUI(args);\n        }\n\n        protected virtual void BeforeRowsGUI()\n        {\n            if (showAlternatingRowBackgrounds)\n                m_GUI.DrawAlternatingRowBackgrounds();\n        }\n\n        protected virtual void AfterRowsGUI()\n        {\n        }\n\n        protected virtual void RefreshCustomRowHeights()\n        {\n            if (!m_OverriddenMethods.hasGetCustomRowHeight)\n                throw new InvalidOperationException(\"Only call RefreshCustomRowHeights if you have overridden GetCustomRowHeight to customize the height of each row.\");\n            m_GUI.RefreshRowRects(GetRows());\n        }\n\n        protected virtual float GetCustomRowHeight(int row, TreeViewItem<TIdentifier> item) => GetCustomRowHeightInternal(row, item);\n\n        internal virtual float GetCustomRowHeightInternal(int row, TreeViewItem<TIdentifier> item)\n        {\n            return rowHeight;\n        }\n\n        protected virtual Rect GetRenameRect(Rect rowRect, int row, TreeViewItem<TIdentifier> item) => GetRenameRectInternal(rowRect, row, item);\n\n        internal virtual Rect GetRenameRectInternal(Rect rowRect, int row, TreeViewItem<TIdentifier> item)\n        {\n            return m_GUI.DefaultRenameRect(rowRect, row, item);\n        }\n\n        protected virtual void CommandEventHandling()","sourceCodeStart":678,"sourceCodeEnd":714,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs#L678-L714","documentation":"Thrown by RefreshCustomRowHeights when the TreeView subclass has not overridden GetCustomRowHeight. The custom row-height system only works when the subclass provides per-row height logic; calling RefreshCustomRowHeights without the override means there are no custom heights to compute.","triggerScenarios":"Calling RefreshCustomRowHeights() in a TreeView subclass that does not override GetCustomRowHeight; calling it in the base TreeView; the override was removed during refactoring but the refresh call was left behind.","commonSituations":"Copy-pasting TreeView code that includes RefreshCustomRowHeights but omitting the GetCustomRowHeight override; conditional custom-height logic that calls refresh in a branch without the override.","solutions":["Override GetCustomRowHeight in your TreeView subclass before calling RefreshCustomRowHeights.","If you do not need custom heights, remove the RefreshCustomRowHeights call and use fixed rowHeight instead.","Verify the override is declared with the correct signature: protected override float GetCustomRowHeight(int row, TreeViewItem<TIdentifier> item)."],"exampleFix":"// before\nclass MyTree : TreeView<int> {\n    void OnSomething() { RefreshCustomRowHeights(); } // no override\n}\n\n// after\nclass MyTree : TreeView<int> {\n    protected override float GetCustomRowHeight(int row, TreeViewItem<int> item)\n        => item.depth == 0 ? 32f : 20f;\n    void OnSomething() { RefreshCustomRowHeights(); }\n}","handlingStrategy":"type-guard","validationCode":"if (m_OverriddenMethods.hasGetCustomRowHeight)\n    RefreshCustomRowHeights();","typeGuard":"static bool HasCustomRowHeightOverride<T>(TreeView<T> tv) => tv.m_OverriddenMethods.hasGetCustomRowHeight; // internal","tryCatchPattern":null,"preventionTips":["Only call RefreshCustomRowHeights after overriding GetCustomRowHeight.","If you do not need custom heights, use fixed rowHeight instead.","Keep the override and the refresh call in the same subclass."],"tags":["unity","treeview","custom-row-height","invalid-operation","override"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}