using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.AI.Navigation; //doest recognize
using UnityEngine.AI; //doest recognize
public class NaviMeshManager : MonoBehaviour
{
public NavigationSurface[] surfaces;
public void UpdateNavigationMesh()
{
surfaces = FindObjectsOfType<NavigationSurface>();
// Update the NavigationSurface
for (int i = 0; i < surfaces.Length; i++)
{
surfaces[i].BuildNavMesh();
}
Debug.Log("updating ALL nav mesh");
}
}
I have the same issue and after further investigation I found that starting a new project doesn’t have this issue. So I’m wondering if there’s a package in my project causing this. I did find a bug report that indicated that the old NavMesh package had to be uninstalled but I don’t have it.
The namespace to use for NavMeshSurface is different, It doesn’t exist in the UnityEngine.AI namespace, it exists in Unity.AI.Navigation, So an example :
using UnityEngine;
using UnityEngine.AI; // Need this for the Normal NavMesh Components
using Unity.AI.Navigation; // Need this for NavMeshSurface
public class Nav : MonoBehaviour
{
// Nav Mesh (Agent & Obstacle) exists in UnityEngine.AI
// NavMeshAgent
[SerializeField] private NavMeshAgent agent;
// NavMeshObstacle
[SerializeField] private NavMeshObstacle obstacle;
// Nav Mesh Surface exists in Unity.AI.Navigation
// NavMeshSurface
// One.
[SerializeField] private NavMeshSurface surface;
// Multiple.
[SerializeField] private NavMeshSurface[] surfaces;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}