navMeshData | 构建过程中特意收集调试数据的寻路网格对象。 |
flags | 指定一次显示的数据类型的位掩码。 |
在编辑器中显示指定寻路网格构建过程中使用的精确中间数据。
using System.Collections.Generic; using UnityEditor.AI; using UnityEngine; using UnityEngine.AI;
public class NavMeshBuildDebugDraw : MonoBehaviour { NavMeshData m_NavMeshData;
void Start() { var bounds = new Bounds(transform.position, new Vector3(100.0f, 100.0f, 100.0f)); var markups = new List<NavMeshBuildMarkup>(); var sources = new List<NavMeshBuildSource>(); NavMeshEditorHelpers.CollectSourcesInStage( bounds, ~0, NavMeshCollectGeometry.RenderMeshes, 0, markups, gameObject.scene, sources);
var settings = NavMesh.GetSettingsByID(0); var debug = new NavMeshBuildDebugSettings(); debug.flags = NavMeshBuildDebugFlags.All; settings.debug = debug;
m_NavMeshData = new NavMeshData(); UnityEngine.AI.NavMeshBuilder.UpdateNavMeshDataAsync(m_NavMeshData, settings, sources, bounds); }
void OnDrawGizmos() { NavMeshEditorHelpers.DrawBuildDebug( m_NavMeshData, NavMeshBuildDebugFlags.Regions | NavMeshBuildDebugFlags.SimplifiedContours); } }