@@ -331,7 +331,7 @@ public override sealed void OnGui(Rect rect)
331
331
return ;
332
332
}
333
333
334
- int levels = ( int ) ( ( rect . x + firstElementXOffset ) / columnSize ) ;
334
+ var levels = ( int ) ( ( rect . x + firstElementXOffset ) / columnSize ) ;
335
335
336
336
if ( levels <= 0 )
337
337
{
@@ -348,26 +348,27 @@ public override sealed void OnGui(Rect rect)
348
348
rect . x = startXPosition ;
349
349
rect . width = columnSize + firstElementWidthOffset ;
350
350
351
- int siblingIndex = target . transform . GetSiblingIndex ( ) ;
351
+ var transf = target . transform ;
352
+ var siblingIndex = transf . GetSiblingIndex ( ) ;
352
353
353
354
if ( levels > levelRenderers . Count )
354
355
{
355
356
//Initialize missing tree line level render
356
- int startIndex = levelRenderers . Count ;
357
+ var startIndex = levelRenderers . Count ;
357
358
int x ;
358
359
for ( x = startIndex ; x < levels ; x ++ )
359
360
{
360
- var levelRenderer = new TreeLineLevelRenderer ( x + 1 ) ;
361
+ var levelRenderer = new TreeLineLevelRenderer ( ) ;
361
362
levelRenderers . Add ( levelRenderer ) ;
362
363
}
363
364
364
365
x -- ;
365
- Transform transf = target . transform ;
366
366
367
+ Transform transfBuf = transf ;
367
368
for ( ; x >= startIndex ; x -- )
368
369
{
369
- levelRenderers [ x ] . Initialize ( transf ) ;
370
- transf = transf . parent ;
370
+ levelRenderers [ x ] . Initialize ( transfBuf ) ;
371
+ transfBuf = transfBuf . parent ;
371
372
}
372
373
}
373
374
@@ -387,16 +388,10 @@ public override sealed void OnGui(Rect rect)
387
388
private class TreeLineLevelRenderer
388
389
{
389
390
private bool renderedLastLevelGameobject = false ;
390
- private int level ;
391
-
392
- public TreeLineLevelRenderer ( int level )
393
- {
394
- this . level = level ;
395
- }
396
391
397
392
public void Initialize ( Transform transf )
398
393
{
399
- int siblingIndex = transf . GetSiblingIndex ( ) ;
394
+ var siblingIndex = transf . GetSiblingIndex ( ) ;
400
395
renderedLastLevelGameobject = GetParentChildCount ( transf ) == ( siblingIndex + 1 ) ;
401
396
}
402
397
@@ -426,16 +421,14 @@ public void OnGUI(Rect rect, GameObject target, int siblingIndex, bool isCurrent
426
421
427
422
private int GetParentChildCount ( Transform target )
428
423
{
429
- if ( level == 1 )
430
- {
431
- var scene = target . gameObject . scene ;
432
- return scene . rootCount ;
433
- }
434
- else
424
+ var parent = target . parent ;
425
+ if ( parent != null )
435
426
{
436
- var parent = target . parent ;
437
427
return parent . childCount ;
438
428
}
429
+
430
+ var scene = target . gameObject . scene ;
431
+ return scene . rootCount ;
439
432
}
440
433
441
434
private int GetParentChildCount ( GameObject target )
0 commit comments