public void Apply() { if (Width == 0 || Height == 0) { Debug.LogError("Cannot create a map segment with the width or height of 0"); return; } if (TileSet == null) { Debug.LogError("Cannot create a map segment without a tile set"); return; } Undo.RegisterCompleteObjectUndo(target, "Changed size and tileset"); MapSegment.Width = Width; MapSegment.Height = Height; MapSegment.TileSet = TileSet; MapSegment.GridTileSize = GridTileSize; TileSet.AddMapSegment(MapSegment); ApplyTilsetChanges(); // The colliders will be out of scale by this and must be adapted UpdateCollider(); EditorUtility.SetDirty(target); }