Skip to content

Commit 45f7498

Browse files
committed
fix: create matrix level
1 parent f14b767 commit 45f7498

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Assets/Code/LevelEditor/LevelMatrixEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
{

Assets/Code/LevelEditor/LevelWindowEditor.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)