[Solved] unity EditorGUILayer dynamic drawing scrolling list error

The specific error message: ArgumentException: Getting control 0’s position in a group with only 0 controls when doing Repaint A

OnGUI will be called two times each time it draws, the first time to calculate the position of all controls, all EdtorGUILayout control method returns the Rect is 0; the second time to draw all the content based on the position, the control method returns the Rect is the actual coordinates.

BeginScrollView to generate a scrolling list, because I need to display a lot of content, so I made an optimization: pre-calculate the position of each line, when the line is in viewport display content, otherwise display blank.

Generic logging found that the height of each row generated by the system is not the same, generally floating randomly between 19-21, so it is impossible to calculate the position of each row, so instead, when the second call to OnGUI, use the Rect returned by the control method to calculate in real time.

 

Read More: