@@ -287,63 +287,84 @@ protected override void LayoutChildren()
287287 protected void ResolveGridLayout ( Vector3 [ ] grid , LayoutOrder order )
288288 {
289289 int cellCounter = 0 ;
290- int iMax , jMax ;
290+ int xMax , yMax ;
291291
292292 switch ( order )
293293 {
294294 case LayoutOrder . RowThenColumn :
295- iMax = Columns ;
296- jMax = Rows ;
295+ xMax = Columns ;
296+ yMax = Rows ;
297297 break ;
298298 case LayoutOrder . ColumnThenRow :
299- iMax = Columns ;
300- jMax = Rows ;
299+ xMax = Columns ;
300+ yMax = Rows ;
301301 break ;
302302 case LayoutOrder . Vertical :
303- iMax = 1 ;
304- jMax = NodeList . Count ;
303+ xMax = 1 ;
304+ yMax = NodeList . Count ;
305305 break ;
306306 case LayoutOrder . Horizontal :
307- iMax = NodeList . Count ;
308- jMax = 1 ;
307+ xMax = NodeList . Count ;
308+ yMax = 1 ;
309309 break ;
310310 default :
311- iMax = Mathf . CeilToInt ( ( float ) NodeList . Count / rows ) ;
312- jMax = rows ;
311+ xMax = Mathf . CeilToInt ( ( float ) NodeList . Count / rows ) ;
312+ yMax = rows ;
313313 break ;
314314 }
315315
316- float startOffsetX = ( iMax * 0.5f ) * CellWidth ;
316+ float startOffsetX = ( xMax * 0.5f ) * CellWidth ;
317317 if ( anchor == LayoutAnchor . BottomLeft || anchor == LayoutAnchor . UpperLeft || anchor == LayoutAnchor . MiddleLeft )
318318 {
319319 startOffsetX = 0 ;
320320 }
321321 else if ( anchor == LayoutAnchor . BottomRight || anchor == LayoutAnchor . UpperRight || anchor == LayoutAnchor . MiddleRight )
322322 {
323- startOffsetX = iMax * CellWidth ;
323+ startOffsetX = xMax * CellWidth ;
324324 }
325325
326- float startOffsetY = ( jMax * 0.5f ) * CellHeight ;
326+ float startOffsetY = ( yMax * 0.5f ) * CellHeight ;
327327 if ( anchor == LayoutAnchor . UpperLeft || anchor == LayoutAnchor . UpperCenter || anchor == LayoutAnchor . UpperRight )
328328 {
329329 startOffsetY = 0 ;
330330 }
331331 else if ( anchor == LayoutAnchor . BottomLeft || anchor == LayoutAnchor . BottomCenter || anchor == LayoutAnchor . BottomRight )
332332 {
333- startOffsetY = jMax * CellHeight ;
333+ startOffsetY = yMax * CellHeight ;
334334 }
335335
336- for ( int i = 0 ; i < iMax ; i ++ )
336+ if ( layout == LayoutOrder . ColumnThenRow )
337337 {
338- for ( int j = 0 ; j < jMax ; j ++ )
338+ for ( int y = 0 ; y < yMax ; y ++ )
339+ for ( int x = 0 ; x < xMax ; x ++ )
340+ {
341+ {
342+ if ( cellCounter < NodeList . Count )
343+ {
344+ grid [ cellCounter ] . Set ( ( - startOffsetX + ( x * CellWidth ) + HalfCell . x ) + NodeList [ cellCounter ] . Offset . x ,
345+ ( startOffsetY - ( y * CellHeight ) - HalfCell . y ) + NodeList [ cellCounter ] . Offset . y ,
346+ 0.0f ) ;
347+ }
348+ cellCounter ++ ;
349+ }
350+ }
351+
352+ }
353+ else
354+ {
355+
356+ for ( int x = 0 ; x < xMax ; x ++ )
339357 {
340- if ( cellCounter < NodeList . Count )
358+ for ( int y = 0 ; y < yMax ; y ++ )
341359 {
342- grid [ cellCounter ] . Set ( ( - startOffsetX + ( i * CellWidth ) + HalfCell . x ) + NodeList [ cellCounter ] . Offset . x ,
343- ( startOffsetY - ( j * CellHeight ) - HalfCell . y ) + NodeList [ cellCounter ] . Offset . y ,
344- 0.0f ) ;
360+ if ( cellCounter < NodeList . Count )
361+ {
362+ grid [ cellCounter ] . Set ( ( - startOffsetX + ( x * CellWidth ) + HalfCell . x ) + NodeList [ cellCounter ] . Offset . x ,
363+ ( startOffsetY - ( y * CellHeight ) - HalfCell . y ) + NodeList [ cellCounter ] . Offset . y ,
364+ 0.0f ) ;
365+ }
366+ cellCounter ++ ;
345367 }
346- cellCounter ++ ;
347368 }
348369 }
349370 }
@@ -435,13 +456,13 @@ private void Awake()
435456#endif
436457 }
437458
438- #region asset version migration
459+ #region asset version migration
439460#if UNITY_EDITOR
440- private const int CurrentAssetVersion = 1 ;
461+ private const int CurrentAssetVersion = 1 ;
441462
442- [ SerializeField ]
443- [ HideInInspector ]
444- private int assetVersion = 0 ;
463+ [ SerializeField ]
464+ [ HideInInspector ]
465+ private int assetVersion = 0 ;
445466
446467 private void PerformVersionPatching ( )
447468 {
0 commit comments