File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -260,7 +260,7 @@ public IEnumerable<Vector2Int> GetAllOfType(BlockDataEditor type)
260260
261261 private void OnValidate ( ) => ValidateGrid ( ) ;
262262
263- private void ValidateGrid ( ) => ResizeGrid ( ) ;
263+ public void ValidateGrid ( ) => ResizeGrid ( ) ;
264264
265265 private void ResizeGrid ( )
266266 {
Original file line number Diff line number Diff line change @@ -56,11 +56,16 @@ private void CreateNewLevelEditor()
5656 if ( SelectedLevelType == LevelType . Matrix )
5757 {
5858 var matrixEditor = CreateInstance < LevelMatrixEditor > ( ) ;
59+ matrixEditor . name = NewLevelName ;
5960 matrixEditor . IndexLevel = NewIndexLevel ;
60- matrixEditor . Grid = new LevelCell [ NewLevelWidth , NewLevelHeight ] ;
61- for ( int y = 0 ; y < NewLevelHeight ; y ++ )
62- for ( int x = 0 ; x < NewLevelWidth ; x ++ )
63- matrixEditor . Grid [ x , y ] = new LevelCell ( ) ;
61+
62+ var serializedObject = new SerializedObject ( matrixEditor ) ;
63+ serializedObject . FindProperty ( "width" ) . intValue = NewLevelWidth ;
64+ serializedObject . FindProperty ( "height" ) . intValue = NewLevelHeight ;
65+ serializedObject . ApplyModifiedPropertiesWithoutUndo ( ) ;
66+
67+ matrixEditor . ValidateGrid ( ) ;
68+
6469 newEditor = matrixEditor ;
6570 }
6671 else if ( SelectedLevelType == LevelType . Hexagon )
You can’t perform that action at this time.
0 commit comments