@@ -14,6 +14,10 @@ private static void Open() {
1414 GetWindow < EcsLiteHierarchyWindow > ( "ecsLite Hierarchy" ) . Show ( ) ;
1515 }
1616
17+ private static readonly Color32 _selectedColor = new Color32 ( 44 , 93 , 135 , 255 ) ;
18+ private static readonly Color32 _colorInterval1 = new Color32 ( 56 , 56 , 56 , 255 ) ;
19+ private static readonly Color32 _colorInterval2 = new Color32 ( 88 , 88 , 88 , 255 ) ;
20+
1721 private DropdownField _worldMenu ;
1822 private Toolbar _toolbar ;
1923 private ToolbarSearchField _searchField ;
@@ -146,7 +150,7 @@ private void UpdateHierarchy() {
146150 child . Q < Label > ( "name" ) . text = mutation . entity . GetPrettyName ( ) ;
147151 break ;
148152 case WorldDebugView . ChangeType . Del :
149- child . Q < Label > ( "name" ) . text = null ;
153+ child . Q < Label > ( "name" ) . text = "-" ;
150154 break ;
151155 default :
152156 throw new ArgumentOutOfRangeException ( ) ;
@@ -158,7 +162,7 @@ private VisualElement CreateEmptyRow(int id, WorldDebugView view) {
158162 Button row = new Button ( ) ;
159163 VisualElement left = new VisualElement ( ) ;
160164 Label index = new Label ( id . ToString ( ) ) ;
161- Label name = new Label ( null ) {
165+ Label name = new Label ( "-" ) {
162166 name = "name"
163167 } ;
164168
@@ -167,23 +171,26 @@ private VisualElement CreateEmptyRow(int id, WorldDebugView view) {
167171 row . Add ( left ) ;
168172 row . Add ( name ) ;
169173
170- int tmpId = id ;
171- WorldDebugView . DebugEntity GetEntity ( ) => view . GetEntities ( ) [ tmpId ] ;
174+ WorldDebugView . DebugEntity GetEntity ( int id ) => view . GetEntities ( ) [ id ] ;
172175 row . clicked += ( ) =>
173176 {
174- EcsLiteInspectorWindow . SetEntity ( view , GetEntity ( ) ) ;
177+ int id = ( int ) row . userData ;
178+ EcsLiteInspectorWindow . SetEntity ( view , GetEntity ( id ) ) ;
179+ FilterEntities ( ) ;
175180 } ;
176181
177182 left . style . minWidth = new StyleLength ( new Length ( 30 , LengthUnit . Pixel ) ) ;
178183 left . style . backgroundColor = new StyleColor ( new Color32 ( 45 , 45 , 45 , 255 ) ) ;
179-
180- index . style . SetPadding ( new StyleLength ( new Length ( 2 , LengthUnit . Pixel ) ) ) ;
181184
185+ row . name = "entity-row" ;
186+ row . userData = id ;
187+
182188 row . style . flexDirection = new StyleEnum < FlexDirection > ( FlexDirection . Row ) ;
183189 row . style . flexWrap = new StyleEnum < Wrap > ( Wrap . NoWrap ) ;
184190 row . style . SetPadding ( 0 ) ;
185191 row . style . SetMargin ( 0 ) ;
186192 row . style . SetBorderRadius ( 0 ) ;
193+ row . style . SetBorderWidth ( 0 ) ;
187194 row . style . backgroundImage = null ;
188195
189196 name . style . flexWrap = new StyleEnum < Wrap > ( Wrap . NoWrap ) ;
@@ -201,6 +208,8 @@ private void FilterEntities() {
201208 string filter = _searchField . value . ToLower ( ) ;
202209 int i = 0 ;
203210
211+ bool hasSelected = EcsLiteInspectorWindow . TryGetEntity ( out int entityId ) ;
212+
204213 foreach ( VisualElement child in _hierarchy . Children ( ) ) {
205214 Label name = child . ElementAt ( 1 ) as Label ;
206215 string text = name . text . ToLower ( ) ;
@@ -213,11 +222,18 @@ private void FilterEntities() {
213222 child . style . height = show ? StyleKeyword . Auto : 0 ;
214223 child . style . display = new StyleEnum < DisplayStyle > ( show ? DisplayStyle . Flex : DisplayStyle . None ) ;
215224
216- if ( show ) {
217- Color color = i % 2 == 0 ? new Color32 ( 56 , 56 , 56 , 255 ) : new Color32 ( 88 , 88 , 88 , 255 ) ;
218- child . style . backgroundColor = new StyleColor ( color ) ;
219- i ++ ;
225+ if ( ! show ) {
226+ continue ;
220227 }
228+
229+ int id = ( int ) child . userData ;
230+ Color color = hasSelected && id == entityId
231+ ? _selectedColor
232+ : i % 2 == 0
233+ ? _colorInterval1
234+ : _colorInterval2 ;
235+ child . style . backgroundColor = new StyleColor ( color ) ;
236+ i ++ ;
221237 }
222238
223239 _hierarchy . MarkDirtyRepaint ( ) ;
0 commit comments