Bug - Draw Mesh Surface

Hi Aron.

I tried the new “Draw Mesh Surface” option, and I get this error in the console:

DrawMesh requires material.SetPass before!
UnityEngine.Graphics:DrawMeshNow(Mesh, Matrix4x4)
Pathfinding.RecastGraphEditor:OnDrawGizmos() (at Assets/AstarPathfindingProject/Editor/GraphEditors/RecastGraphEditor.cs:288)
AstarPathEditor:OnDrawGizmos() (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:1504)
AstarPath:OnDrawGizmos() (at Assets/AstarPathfindingProject/Core/AstarPath.cs:768)
UnityEditor.DockArea:OnGUI()

This actually freezes the scene if it is large enough, and I had to terminate the unity process to move forward.

Huh, that’s odd. It works perfectly fine for me… and when I look at the code I see that it does call SetPass immediately before calling DrawMeshNow.

What Unity version/platform are you using?

5.3.2f1 , on windows

Hm… from the stacktrace it looks like it is coming from the second part of the mesh rendering.
I.e RecastGraphEditor.OnDrawGizmos -> outline mesh drawing (not surface mesh). Do you think you could verify that that is true?

navmeshOutlineMaterial.SetPass(0);
for (int i = 0; i < gizmoMeshes.Count; i++) {
Graphics.DrawMeshNow(gizmoMeshes[i].outlineMesh, Matrix4x4.identity);
}

this is the culprit.

however, it only fires when Show Mesh surface is checked.

it fires if draw mesh outline is checked or not. and mesh outline draws fine.

The outline that is drawn there is not the same outline as the toggle in the inspector mentions.

Ok, so that is odd because then apparently rendering of the surface mesh works fine.
Do you think you could check what the return value of the SetPass call is? It should return a boolean.

yeah.

it returns true

and commenting out that part i listed above (lines 286 - 289) draws the mesh correctly (as far as I can tell) and removes the error.

BTW, i’m also noticing that when I load the cache, or start the scene, the draw mesh surface toggles reverts to false.

Odd…

All graph settings are also stored in the cache, and that includes the draw mesh surface toggle. You can resave the cache to save the new settings.

ok, yeah, that was my issue.

What does that outline part draw? it doesn’t seem to have any problems drawing the mesh if i remove that part.

It draws an outline of the mesh pretty similar to the one drawn for the outline toggle, but it doesn’t use unity gizmos, so it is a lot faster. I am planning to migrate the code that uses unity gizmos right now to use meshes instead for performance.

If anyone else is seeing this bug, please post here so that I might be able to track down what platform/unity version combination that is causing it.

I am also having this bug,

I told my source control to ignore meta files in the plugins folder, and now all my A* components are “missing” . I reassigned everything, and set it all up again, but I get this error and cant play the scene.
commenting out :

Graphics.DrawMeshNow(meshes[i].mesh, Matrix4x4.identity);

prevents the error but ofc cant draw the navmesh now

That’s bad. Don’t do that. The meta files are important. If those are gone you will have to reinstall the pathfinding package. Delete your AstarPathfindingProject folder and import the package again.