@@ -43,9 +43,11 @@ public static void ShowExample()
4343 // Variables used for refresh view
4444 private bool doRefresh ;
4545 private int cachedSceneHandle ;
46+ private Vector3 cachedCamPos ;
4647 private int totalLightCount ;
4748 private int totalShadowCount ;
48- private Vector3 cachedCamPos ;
49+ private string [ ] cachedLightNames ;
50+ private string [ ] cachedShadowCasterNames ;
4951
5052 ILight2DCullResult lightCullResult
5153 {
@@ -118,6 +120,9 @@ private VisualElement MakePill(UnityEngine.Object obj)
118120 var bubble = new Button ( ) ;
119121 bubble . AddToClassList ( "Pill" ) ;
120122 bubble . text = obj . name ;
123+ bubble . style . maxWidth = 200 ;
124+ bubble . style . overflow = Overflow . Hidden ;
125+ bubble . style . textOverflow = TextOverflow . Ellipsis ;
121126
122127 bubble . clicked += ( ) =>
123128 {
@@ -469,8 +474,20 @@ private bool IsDirty()
469474
470475 if ( lightCullResult . IsGameView ( ) )
471476 {
477+ var visibleShadows = lightCullResult . visibleShadows . SelectMany ( x => x . GetShadowCasters ( ) ) . ToList ( ) ;
478+
472479 isDirty |= totalLightCount != lightCullResult . visibleLights . Count ( ) ;
473- isDirty |= totalShadowCount != lightCullResult . visibleShadows . Count ( ) ;
480+ isDirty |= totalShadowCount != visibleShadows . Count ( ) ;
481+
482+ // Account for name changes
483+ if ( ! isDirty )
484+ {
485+ for ( int i = 0 ; i < totalLightCount ; ++ i )
486+ isDirty |= ! lightCullResult . visibleLights . Exists ( x => x != null && x . name == cachedLightNames [ i ] ) ;
487+
488+ for ( int i = 0 ; i < totalShadowCount ; ++ i )
489+ isDirty |= ! visibleShadows . Exists ( x => x != null && x . name == cachedShadowCasterNames [ i ] ) ;
490+ }
474491 }
475492
476493 return isDirty ;
@@ -485,8 +502,27 @@ private void ResetDirty()
485502
486503 if ( lightCullResult != null )
487504 {
505+ var visibleShadows = lightCullResult . visibleShadows . SelectMany ( x => x . GetShadowCasters ( ) ) ;
506+
488507 totalLightCount = lightCullResult . visibleLights . Count ( ) ;
489- totalShadowCount = lightCullResult . visibleShadows . Count ( ) ;
508+ totalShadowCount = visibleShadows . Count ( ) ;
509+
510+ cachedLightNames = new string [ totalLightCount ] ;
511+ cachedShadowCasterNames = new string [ totalShadowCount ] ;
512+
513+ for ( int i = 0 ; i < totalLightCount ; ++ i )
514+ {
515+ var light = lightCullResult . visibleLights [ i ] ;
516+ if ( light != null )
517+ cachedLightNames [ i ] = light . name ;
518+ }
519+
520+ for ( int i = 0 ; i < totalShadowCount ; ++ i )
521+ {
522+ var shadowCaster = visibleShadows . ElementAt ( i ) ;
523+ if ( shadowCaster != null )
524+ cachedShadowCasterNames [ i ] = shadowCaster . name ;
525+ }
490526 }
491527
492528 doRefresh = false ;
0 commit comments