创建__等距瓦片地图 (Isometric Tilemap)__ 时,与创建常规瓦片地图相比,还需要执行其他步骤。要创建等距瓦片地图,请选择 GameObject > 2D Object > Isometric Tilemap/Isometric Z as Y Tilemap。
创建等距瓦片地图后,还需要通过项目和网格设置进行其他设置,才能正确渲染等距瓦片地图。
为了渲染等距瓦片地图的瓦片,需要先渲染远离瓦片地图“背面”的瓦片,然后再渲染正面的瓦片,从而创建等距透视图的__伪深度__。为了确保场景中的所有渲染器都符合此逻辑,请使用自定义轴 (Custom Axis) 作为排序轴 (Sorting Axis)。将 Transparency Sort Mode 设置为“Custom Axis”,并为 Transparency Sort Axis 的 XYZ 值输入 (0,1,0)。
选择 Edit > Project Settings…> Graphics > Camera Settings 来设置“Custom Axis”设置。
将 Transparency Sort Axis XYZ 值设置为 (0,1,0) 会使场景中位于较大 Y 位置的所有渲染器首先渲染,并出现在较小 Y 位置的渲染器后面。
使用 Isometric Z as Y Tilemap 选项时,具有不同 Z 位置值的瓦片会沿 Y 轴偏移并且看起来处于不同的高度,从而在相同的 XY 单元位置处产生与瓦片的“堆叠”效果。默认情况下,通用的等距 Transparency Sort Axis 设置 (0,1,0) 不会在排序期间考虑瓦片的 Z 位置值,因此会导致瓦片不按预期顺序渲染(请参阅下面的示例)。
将 Transparency Sort Axis 设置为 (0,1,–0.26) 可正确渲染具有不同 Z 位置的瓦片。Z 轴设置为 –0.26 可为需要首先绘制并具有较高 Z 位置的瓦片提供一个偏差。
Isometric | Creates an Isometric Tilemap with the default settings. |
Isometric Z As Y | Creates an Isometric Tilemap where a Tile’s Z-axis value is added to its Y-axis value. This causes the Tile to be visually offset along the Y-axis by that value, creating the illusion of height as the Tiles are placed on the Tilemap. |
等距瓦片地图使用__二维投影__或真__等距投影__平行投影角度。有关这两种投影形式的更多信息,请参阅此文章以获取更多详细信息。
更改 Grid 组件的 Cell Size 会更改组成每个单元格的角度大小,这会影响所模拟的投影类型。默认情况下,Isometric Cell Layout 的 Cell Size 为 (1, 0.5, 1),用于模拟__二维投影__角度。要模拟真__等距投影__角度,请将 Y 值设置为 0.57735。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.