From the course: Unity 5: 2D Building a Tile Map Editor

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Calculating the map size

Calculating the map size

- At this point, we have enough to calculate the actual size of the grid that our tile map will take up. In order to do this, we're going to multiply the tile map size by the actual tile size. Let's go back into our tile map and create a new public field that'll store the grid size. Here we'll make this a new Vector2. Now, let's go back into the TileMapEditor, and just below where we calculate the actual tile size, we're going to set the new grid size. We'll do this by creating a new Vector2. Before we actually use the real width of the tile size, we're going to need to make a small adjustment for the pixels to units. As you can see, I'm going to use the width from our tile and I'm going to divide this by 100. If you remember back to when we created our sprite, we didn't change the pixels to unit conversion, so it's set to 100. This will actually give us the real world space for how large our tile map is going to be. Let's multiply this by the map size, x, and we'll do the same for…

Contents