NavMeshPlus
NavMeshPlus copied to clipboard
NavMesh Surface not Visible in Scene View Without "AI Navigation" Unity Package
Hey all. I was encountering an issue where I could not see the NavMesh surface in the scene view after baking the mesh. I resolved this issue by going to Window > Package Manager > Select "Unity Registry" > Search "AI Navigation" > Install.
This package seems dependent on that Unity package (at least for showing the NavMesh in the scene view) but this is not mentioned in any of the documentation I could find.
I will check. Unity hide everything into new package
For context, this was on Unity 2022.3.10f1, 2D URP preset
For what reason, you copy and use the navigation package's code in this asset? Shall we just use the unity's ai navigation package? @h8man
In my case, "AI navigation" has already installed before I use this package. However, I have to remove and install it again to make bake work correctly and visible in scene view. Hope it will help someone with same problem.
On Unity 6000.0.44f1 I tried with and without Unity's AI Navigation package 2.0.6 and by installing via github link or manifest : I can't see the surface. Is it a known issue for Unity 6000 ?
Having the same problem as @QuentinNev : I'm on Unity 6000.0.43f1 and with or without AI Navigation package, the navigation mesh is not visible.
BTW, I temporarily solved the problem by putting together a script that shows the mesh in edit mode:
using UnityEngine;
public class NavMeshDisplay : MonoBehaviour
{
#if UNITY_EDITOR
Hash128 meshSignature;
Mesh navigationMesh;
[SerializeField] Color meshColor = new(0, 0, 1, 0.2f);
[SerializeField] Color meshWireColor = new(0, 0, 1, 0.4f);
void OnDrawGizmosSelected()
{
var triangulation = UnityEngine.AI.NavMesh.CalculateTriangulation();
Hash128 hash = new();
foreach ( var i in triangulation.indices )
{
hash.Append( 0 );
hash.Append( i );
}
foreach ( var i in triangulation.vertices )
{
hash.Append( 1 );
hash.Append( i.x );
hash.Append( i.y );
hash.Append( i.z );
}
if ( meshSignature != hash )
{
Debug.Log( "recomputing mesh to draw" );
meshSignature = hash;
navigationMesh ??= new Mesh();
navigationMesh.Clear();
navigationMesh.SetVertices( triangulation.vertices );
navigationMesh.SetTriangles( triangulation.indices, 0 );
navigationMesh.RecalculateNormals();
}
Gizmos.color = meshColor;
Gizmos.DrawMesh( navigationMesh );
Gizmos.color = meshWireColor;
Gizmos.DrawWireMesh( navigationMesh );
}
#endif
}