@@ -51,6 +51,7 @@ class LocksControl
5151 [ NonSerialized ] private GitLockEntry rightClickNextRenderEntry ;
5252 [ NonSerialized ] private int controlId ;
5353 [ NonSerialized ] private UnityEngine . Object lastActivatedObject ;
54+ [ NonSerialized ] private Dictionary < string , bool > visibleItems = new Dictionary < string , bool > ( ) ;
5455
5556 [ SerializeField ] private Vector2 scroll ;
5657 [ SerializeField ] private List < GitLockEntry > gitLockEntries = new List < GitLockEntry > ( ) ;
@@ -106,15 +107,19 @@ public bool Render(Rect containingRect, Action<GitLock> singleClick = null,
106107 var endDisplay = scroll . y + containingRect . height ;
107108
108109 var rect = new Rect ( containingRect . x , containingRect . y , containingRect . width , 0 ) ;
109-
110110 for ( var index = 0 ; index < gitLockEntries . Count ; index ++ )
111111 {
112112 var entry = gitLockEntries [ index ] ;
113113
114114 var entryRect = new Rect ( rect . x , rect . y , rect . width , Styles . LocksEntryHeight ) ;
115115
116- var shouldRenderEntry = ! ( entryRect . y > endDisplay || entryRect . yMax < startDisplay ) ;
117- if ( shouldRenderEntry )
116+ if ( Event . current . type == EventType . Layout )
117+ {
118+ var shouldRenderEntry = ! ( entryRect . y > endDisplay || entryRect . yMax < startDisplay ) ;
119+ visibleItems [ entry . GitLock . ID ] = shouldRenderEntry ;
120+ }
121+
122+ if ( visibleItems [ entry . GitLock . ID ] )
118123 {
119124 entryRect = RenderEntry ( entryRect , entry ) ;
120125 }
@@ -225,6 +230,7 @@ public void Load(List<GitLock> locks, List<GitStatusEntry> gitStatusEntries)
225230 var scrollIndex = ( int ) ( scrollValue / Styles . LocksEntryHeight ) ;
226231
227232 assets . Clear ( ) ;
233+ visibleItems . Clear ( ) ;
228234
229235 gitLockEntries = locks . Select ( gitLock =>
230236 {
@@ -244,6 +250,7 @@ public void Load(List<GitLock> locks, List<GitStatusEntry> gitStatusEntries)
244250 assets . Add ( assetGuid , gitLockEntry ) ;
245251 }
246252
253+ visibleItems . Add ( gitLockEntry . GitLock . ID , false ) ;
247254 return gitLockEntry ;
248255 } ) . ToList ( ) ;
249256
0 commit comments