Forgive me if this is already in the docs for NavMesh.CalculateTriangulation, but I’m trying to understand how NavMesh.CalculateTriangulation correlates (or if it doesn’t) to the NavMeshData references that were dynamically updated via NavMeshBuilder.UpdateNavMesh/UpdateNavMeshAsyc. I’ve been using NavMeshBuilder.UpdateNavMeshAsyc to generate several NavMeshData references. Later on, I use NavMesh.CalculateTriangulation to retrieve the triangle data from the NavMeshData references.
However, there are times I don’t want NavMesh.CalculateTriangulation to include certain NavMeshData instances (I believe Unity is returning all triangles from all NavMeshData instances).
Is there a way to know which NavMeshData instances will be included in the NavMesh.CalcuateTriangulation?
Even if I could, in theory, remove the NavMeshData from the navigation system and allow NavMesh.CalculateTriangulation to work only on the remaining NavMeshData references, do I have the ability I add it back into navigation system? I’m trying to avoid destroying the NavMeshDataInstance as I want to use them later on.
So I did some more experimenting, and it seems NavMesh.RemoveNavMeshData and NavMeshDataInstance.Remove did not remove the NavMeshData references I wanted to remove from Unity’s ‘mysterious internal database of Nav Meshes for NavMesh.CalculateTriangulation’. Sort of a bummer, but I did come up with a temp solution to go around this but I’m not too proud of it (And it may only work for what I am using it for).
It’s late for me (this is kind of the quandary that keeps me up at night), but I’ll try to explain my best for this solution . It’s very possible maybe somebody might come up with a better solution or maybe the good folks at Unity have some API call that I’m missing out .
To exclude the NavMeshData references from NavMesh.CalculateTriangulation , I had to call NavMeshBuilder.UpdateNavMeshData and stuffed an empty List reference to remove the NavMeshData’s vertices/indices from NavMesh.CalculateTriangulation. I know I mentioned that I didn’t want to delete the NavMeshes, but in my case it worked out for me since I didn’t need them anyways.
I hope this helps anyone that runs into a situation like this. Perhaps better ideas can be made from knowing this temp solution approach.
1 Like