Version: 2021.1
等距瓦片地图
创建等距瓦片地图

Importing and preparing Sprites for an Isometric Tilemap

通过将纹理放入 Assets 文件夹,即可将等距瓦片地图的各个瓦片或瓦片图集导入 Unity 项目。选择导入的图像可以在 Inspector 窗口中查看其纹理导入器 (Texture Importer) 设置。

Sprite importer settings.
Sprite importer settings.

导入精灵供等距瓦片地图中使用时,请使用以下建议设置。有关每项设置的更多信息,请参阅 Texture Type: Sprite (2D and UI) 文档。

1.Texture Type - 将此项设置为 Sprite (2D and UI)。瓦片地图不支持其他纹理类型。 2.Sprite Mode - 如果纹理只包含一个精灵,将此项设置为 Single。如果包含多个精灵纹理(例如具有多个瓦片纹理的精灵图集),则设置为 Multiple。 3. Pixels Per Unit (PPU) - This value is the number of pixels that make up one Unity unit for the selected Sprite. This determines the size of the Sprite when it is rendered on the Tilemap. This is also affected by the Cell Size setting of the Grid that contains the Tilemap, which determines how many Unity units make up a single Cell. Refer to the example below to see how PPU values and the Grid’s Cell Size settings interact. 4. Mesh Type - Set to Tight to ensure the Tile Meshes follow the outline of the imported Sprites, and the Tiles are drawn flush together on the Tilemap. Due to the general diamond shape of most Isometric Tiles, setting this to Full Rect may result in drawing of wasted transparent spaces at the corners of an Isometric Tile, and is not recommended. 5. Generate Physics Shape - If the Tiles do not need to interact with Physics2D, then clear this option. Leave this option enabled to generate a Physics Shape based on the shape of the Tile Sprite, for use with the Tilemap Collider component. To make the generated Physics Shape match the cell of the Tilemap instead, select the Tile Asset and set its Collider Type property to Grid.

在下面的示例中,导入的精灵为 256x128 的图像,且等距瓦片地图的 Cell Size 为(XYZ:1, 0.5, 1)Unity 单位。要使精灵完全适合瓦片地图的单个单元格,请将其 PPU 值设置为 256。然后,精灵的整个宽度对应于一个 Unity 单位:等于单个单元格的宽度(X 值:1)。

左:__设置为 256 PPU 的精灵。右:__设置为 128 PPU 的同一个精灵。
左:__设置为 256 PPU 的精灵。右:__设置为 128 PPU 的同一个精灵。

If the Sprite is set to a PPU value of 128, then it becomes 2 (256px/128) Unity units in width. This causes the Sprite to visually appear to cover 2 Cells in width when painted on the Tilemap. However, the original Cell position of the Tile remains unchanged.

After the Sprites are imported, refine the outlines of the Sprites by opening the Sprite Editor for each of them and editing their outlines. For Sprites in an Isometric Tilemap, you should set the Pivot of the Sprite so that the ‘ground’ is relative to the Sprite.

如果在将 Sprite Mode 设置为 Multiple 的条件下导入纹理并且纹理包含多个精灵,则应在 Sprite Editor 中编辑每个精灵的轮廓。


  • 2018.3 版中添加了等距瓦片地图 NewIn20183
等距瓦片地图
创建等距瓦片地图