I wonder if there is a utility function to get the area of a NavMesh or at least a way to access the geometry so that I can write my own functions of accessing this.

Found a solution and made this in case someone else needs stuff like this

```
public static class NavMeshExtensions {
public static float navMeshArea;
public static float CalculateNavmeshArea() {
var navMesh = NavMesh.CalculateTriangulation();
var mesh = new Mesh();
mesh.vertices = navMesh.vertices;
mesh.triangles = navMesh.indices;
navMeshArea = mesh.CalculateSurfaceArea();
return navMeshArea;
}
public static float CalculateSurfaceArea(this Mesh mesh) {
var triangles = mesh.triangles;
var vertices = mesh.vertices;
double sum = 0.0;
for (int i = 0; i < triangles.Length; i += 3) {
Vector3 corner = vertices[triangles[i]];
Vector3 a = vertices[triangles[i + 1]] - corner;
Vector3 b = vertices[triangles[i + 2]] - corner;
sum += Vector3.Cross(a, b).magnitude;
}
return (float)(sum / 2.0);
}
}
```

1 Like