{"record":{"id":"591f2f52a96aaf1e","repo":"egametang/ET","slug":"nav-load-fail-name","errorCode":null,"errorMessage":"nav load fail: {name}","messagePattern":"nav load fail: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"Packages/cn.etetet.recast/Scripts/Hotfix/Share/PathfindingComponentSystem.cs","lineNumber":22,"sourceCode":"using DotRecast.Core;\nusing DotRecast.Detour;\nusing DotRecast.Detour.Io;\nusing Unity.Mathematics;\n\nnamespace ET\n{\n    [EntitySystemOf(typeof(PathfindingComponent))]\n    public static partial class PathfindingComponentSystem\n    {\n        [EntitySystem]\n        private static void Awake(this PathfindingComponent self, string name)\n        {\n            self.Name = name;\n            self.navMesh = NavmeshComponent.Instance.Get(name);\n            \n            if (self.navMesh == null)\n            {\n                throw new Exception($\"nav load fail: {name}\");\n            }\n            \n            self.filter = new DtQueryDefaultFilter();\n            self.query = new DtNavMeshQuery(self.navMesh);\n        }\n\n        [EntitySystem]\n        private static void Destroy(this PathfindingComponent self)\n        {\n            self.Name = string.Empty;\n            self.navMesh = null;\n        }\n        \n        public static void Find(this PathfindingComponent self, float3 start, float3 target, List<float3> result)\n        {\n            if (self.navMesh == null)\n            {\n                Log.Debug(\"寻路| Find 失败 pathfinding ptr is zero\");","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.recast/Scripts/Hotfix/Share/PathfindingComponentSystem.cs#L4-L40","documentation":"PathfindingComponent.Awake looks up the named navmesh via NavmeshComponent.Instance.Get(name) and throws if the result is null — i.e. the nav data was never loaded under that name. Get uses dictionary indexing internally, so in practice this fires when Load(name) was never awaited before the component awoke.","triggerScenarios":"Constructing a PathfindingComponent with a name for which NavmeshComponent.Instance.navmeshs has no entry, or whose entry is null. Triggered when an entity with a PathfindingComponent is created before NavmeshComponent.Load(name) completes.","commonSituations":"Forgetting to call NavmeshComponent.Instance.Load(mapName) at server startup before spawning pathfinding-using entities; a typo in the map name; loading the map asynchronously but spawning an NPC before the await returns; map file missing so Load silently produced nothing.","solutions":["Ensure NavmeshComponent.Instance.Load(mapName) is awaited before any PathfindingComponent using that name is created.","Verify the map name string matches exactly (case, suffix) across load and component construction sites.","Confirm the recast file exists and isn't empty so Load actually populates the dictionary (else error 314 fires first).","If loading is async, gate entity spawning on the load completion (await the Load in scene init)."],"exampleFix":"// before: entity spawned before nav loads\nentity.AddComponent<PathfindingComponent, string>(mapName);\nawait NavmeshComponent.Instance.Load(mapName);\n// after: load first, then spawn\nawait NavmeshComponent.Instance.Load(mapName);\nentity.AddComponent<PathfindingComponent, string>(mapName);","handlingStrategy":"validation","validationCode":"// Before constructing PathfindingComponent, ensure nav data is loaded\nawait NavmeshComponent.Instance.Load(mapName);\nif (NavmeshComponent.Instance.Get(mapName) == null)\n    throw new InvalidOperationException($\"Navmesh '{mapName}' failed to load; cannot create PathfindingComponent\");\nentity.AddComponent<PathfindingComponent, string>(mapName);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always await NavmeshComponent.Instance.Load at scene init before spawning pathfinding entities.","Centralize map-name strings to avoid typos.","Log when Load populates the dictionary so init ordering bugs surface early."],"tags":["recast","pathfinding","navmesh","initialization","missing-data"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}