@@ -21,6 +21,7 @@ public class TriListElement : TriElement
2121 private readonly ReorderableList _reorderableListGui ;
2222 private readonly bool _alwaysExpanded ;
2323 private readonly bool _showElementLabels ;
24+ private readonly bool _showAlternatingBackground ;
2425
2526 private float _lastContentWidth ;
2627 private int ? _lastInvisibleElement ;
@@ -35,6 +36,7 @@ public TriListElement(TriProperty property)
3536 _property = property ;
3637 _alwaysExpanded = settings ? . AlwaysExpanded ?? false ;
3738 _showElementLabels = settings ? . ShowElementLabels ?? false ;
39+ _showAlternatingBackground = settings ? . ShowAlternatingBackground ?? true ;
3840 _reorderableListGui = new ReorderableList ( null , _property . ArrayElementType )
3941 {
4042 showDefaultBackground = settings ? . ShowDefaultBackground ?? true ,
@@ -43,6 +45,7 @@ public TriListElement(TriProperty property)
4345 displayRemove = settings == null || ! settings . HideRemoveButton ,
4446 drawHeaderCallback = DrawHeaderCallback ,
4547 elementHeightCallback = ElementHeightCallback ,
48+ drawElementBackgroundCallback = DrawElementBackgroundCallback ,
4649 drawElementCallback = DrawElementCallback ,
4750 onAddCallback = AddElementCallback ,
4851 onRemoveCallback = RemoveElementCallback ,
@@ -409,6 +412,23 @@ private void DrawHeaderCallback(Rect rect)
409412 Event . current . Use ( ) ;
410413 }
411414 }
415+
416+ private void DrawElementBackgroundCallback ( Rect rect , int index , bool isActive , bool isFocused )
417+ {
418+ if ( _lastInvisibleElement . HasValue && index + 1 < _lastInvisibleElement . Value ||
419+ _lastVisibleElement . HasValue && index - 1 > _lastVisibleElement . Value )
420+ {
421+ return ;
422+ }
423+
424+ if ( _showAlternatingBackground && index % 2 != 0 )
425+ {
426+ EditorGUI . DrawRect ( rect , new Color ( 0.1f , 0.1f , 0.1f , 0.15f ) ) ;
427+ }
428+
429+ ReorderableList . defaultBehaviours . DrawElementBackground ( rect , index , isActive , isFocused ,
430+ _reorderableListGui . draggable ) ;
431+ }
412432
413433 private void DrawElementCallback ( Rect rect , int index , bool isActive , bool isFocused )
414434 {
0 commit comments