1

how to bake NavMesh in runtime from script. I searched in Google but did not find.
some rendered scene and buttons including bake

4

3 回答 3

7

Currently, Unity doesn't have a way to bake but NavMesh at runtime BUT there is an experimental package that Unity has that allows you bake a NavMesh at runtime. It is very stable package.

There were tutorials made by Brackeys in collaboration with Unity.

The demo project is available for download on GitHub. You can use in the scripts in there to bake a runtime NavMesh.

I would highly recommend watching the tutorial first.

Here is also the link for Unity's site and tutorials on runtime navmesh.

于 2018-09-06T20:44:03.517 回答
-1
using UnityEditor.AI; //"Editor" not "Engine"

NavMeshBuilder.ClearAllNavMeshes();
NavMeshBuilder.BuildNavMesh();
于 2021-02-20T18:57:57.937 回答
-3

AlienCode 的答案非常适合在运行时烘焙 NavMesh,
因为您不能同时拥有两个 using 标签 ( UnityEditor.AI & UnityEngine.AI)

我创建了一个单独的脚本并将其用于烘焙 NavMesh。
我不确定它是否仅适用于编辑器或构建。

于 2021-07-18T03:32:29.213 回答