NavMeshPlus icon indicating copy to clipboard operation
NavMeshPlus copied to clipboard

NavMesh Surface not Visible in Scene View Without "AI Navigation" Unity Package

Open The-Bush opened this issue 1 year ago • 5 comments

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.

The-Bush avatar May 30 '24 01:05 The-Bush

I will check. Unity hide everything into new package

h8man avatar May 31 '24 10:05 h8man

For context, this was on Unity 2022.3.10f1, 2D URP preset

The-Bush avatar Jun 01 '24 00:06 The-Bush

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

dongfangliu avatar Aug 27 '24 02:08 dongfangliu

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.

1severus1 avatar Mar 30 '25 13:03 1severus1

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 ?

QuentinNev avatar Apr 04 '25 12:04 QuentinNev

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.

RedGlow avatar Jun 24 '25 18:06 RedGlow

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
}

RedGlow avatar Jun 25 '25 18:06 RedGlow