__网格__构成了 3D 世界的很大一部分。Unity 提供了一个称为 ProBuilder 的建模工具,另外还有一些 Asset Store 建模插件,例如 Mesh Deformer、UModeler 和 Mesh Editor。而且 Unity 与大多数 3D 建模软件之间有很好的交互性。
Unity 支持三角或四边的多边形网格,因此必须将 Nurbs、Nurms 和 Subdiv 表面转换为多边形。
Unity 遵循特定的搜索计划在导入时自动查找网格使用的纹理。首先,导入器在与网格相同的文件夹中或任何父文件夹中查找名为 Textures 的子文件夹。如果此过程失败,Unity 将对项目中的所有纹理执行穷尽搜索。虽然速度只是稍慢,但穷尽搜索的主要缺点是项目中可能有两个或多个同名的纹理。在这种情况下,不能保证 Unity 可以找到合适的纹理。
(A) 可能找到纹理的地方
(B) 正在导入的网格
如果从 Material Creation Mode 下拉菜单中选择 Standard 或 Import via MaterialDescription (Experimental),然后从 Location 下拉菜单中选择 __Use Embedded Materials__,Unity 将执行以下操作:
有关更多信息,请参阅 Materials 选项卡参考页面。
Unity 使用两种主要类型的碰撞体:网格碰撞体和原始碰撞体。网格碰撞体是使用导入网格数据的组件,可由 Unity 用于环境碰撞。在 Model 选项卡上启用 Generate Colliders 后,Unity 会在您将网格添加到场景中时自动添加一个网格碰撞体,以便物理系统将其视为实体。
如果游戏对象正在移动(例如汽车),则无法使用网格碰撞体。必须改用原始碰撞体。此情况下应禁用 Generate Colliders 设置。
可从模型文件导入动画。请先遵循从 3D 建模软件导出 FBX 文件的指南,再将文件导入 Unity。
如果一个角色具有从模型的复杂多边形版本生成的法线贴图,则应导入平滑角为 180 度的游戏质量版本。这样可以防止由于切线分裂而导致光照中出现看起来奇怪的接缝。如果使用这些设置后仍然存在接缝,请从 Tangents 下拉菜单中选择 Calculate Legacy With Split Tangents。如果是将灰度图像转换为法线贴图,则无需担心这一点。
如需了解如何将混合形状从 3D 建模应用程序导入 Unity 中,请参阅 Model Import Settings 窗口 Model 选项卡的相关文档。
尽可能将网格合并在一起。这些网格应该尽可能共享材质和纹理。这种做法可大幅提升性能。
如果需要在 Unity 中进一步设置游戏对象(添加物理设置、脚本或其他组件),请确保在 3D 应用程序中妥善命名游戏对象。使用 pCube17 或 Box42 之类的名称可能会很费力。
使网格在 3D 建模应用程序中的世界原点居中。这样可以使网格更容易在 Unity 中定位。
如果网格没有顶点颜色,Unity 会在第一次渲染网格时自动将全白色顶点颜色数组添加到网格。
Unity Editor 显示太多顶点或三角形(与 3D 建模应用程序中的原始模型相比)。
这是正常的。您正在查看的是实际发送到 GPU 进行渲染的顶点/三角形数量。除了材质要求发送两次这些顶点/三角形的情况之外,其他诸如硬法线和非连续 UV 的元素与 3D 建模应用程序显示的情况相比会显著增加顶点/三角形数量。三角形在 3D 和 UV 空间中都需要处于连续状态以形成条带,因此当有 UV 接缝时,必须使三角形退化以形成条带,而这会增加计数。
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.