The type or namespace name `NavMeshSurface' could not be found.

Hi, I was looking at this tutorial (Runtime NavMesh Generation - Unity Learn) when I realized that the NavMeshSurface cannot be found.

Am I missing something? I added using UnityEngine.AI and public NavMeshSurface[ ] surfaces; and it gives me the Error.

Hope someone can help me. I am creating a procedural level out of a bunch of Prefabs (as walls) and a primitive plane as floor. So I guess I’ll need to set the prefabs child cube meshes Navigation Static true and not Walkable. However untill the namespace issue isn’t solved the rest won’t make sense anyways.

Did you download the assets used in the tutorial and add them to your project?

1 Like

Maybe it’s not in the engine yet? GitHub - Unity-Technologies/NavMeshComponents: High Level API Components for Runtime NavMesh Building

1 Like

GroZZler, actually I put them into a wrong folder. However, no I get a bunch of warnings about obsolete things. I’ll see if i get it to work now. Thanks for pointing me to it

LurkingNinjaDev, didn’t think about this being the case

ok… so now I got a general question. How would I add the instances created from the script to surfaces?
for example in a loop i create walls:
GameObject wall = (GameObject)Instantiate (Wall, pos, Quaternion.AngleAxis (0, Vector3.up));

how can i add those wall objects to the NavMeshSurface[ ]?

The tutorial talks about procedural levels but doesn’t seem to show how to do it for real procedural level.

…nevermind, i think i was doing something totally stupid :smile:… now i am examining NavMeshModifier…

How did you solve the problem, i have the same

…same issue, unity 2020

just found this myself, you have to download the NavMeshSurface Component from github: GitHub - Unity-Technologies/NavMeshComponents: High Level API Components for Runtime NavMesh Building. that video explains how to use it
https://www.youtube.com/watch?v=e9hr3xM-IvA

3 Likes
  1. install the package from the packagemanger through name or git-url.
  2. import the library in your script:
    using Unity.AI.Navigation;

Solved it for me.

4 Likes

using Unity.AI.Navigation;//??? I can’t seem to access it. It won’t even let me do

using Unity.AI;

Am I missing something? And forget about installing it by github repository URL that didn’t work either. Burst is the first subdirective I get there is no A-section for Unity. It starts with B.

I could not find the reference Unity.AI.Navigation after installing the package. So I went to Package Manager settings in project settings and checked “Enable pre-release packages” in Package Manager settings. I then restarted my project… and it worked! - Not sure if I needed to enable that setting, maybe restart was enough.

Hopefully this might help someone, I had to import the AI Navigation package and then go to the Package Manager and download the samples of the package, scripts reloaded and I was able to use Unity.AI after this

Thank you very much, I was gonna search it for weeks.

1 Like

I have done ALL of this. Adjusted project setting. Imported the navmesh components as well as the samples, and i STILL get missing namespace error.

After downloading the code from github to my project:

using UnityEngine;
using UnityEngine.AI;

[RequireComponent(typeof(NavMeshSurface))]
public class NavMeshTest : MonoBehaviour { 
// don't forget to build out class 
}

etc etc

I got the same error Upgrading 2022.1.15 to → 2022.2.1
Here is how I solve it:

  • I was using the github (now deprecated) GitHub - Unity-Technologies/NavMeshComponents: High Level API Components for Runtime NavMesh Building

  • If your project still had that, time to remove it. Unity already packed this thing in official package list. (via com.unity.ai.navigation)

  • RESTART your editor once! Else assembly will not reload and editor wont see new namespace Unity.AI.Navigation

  • After editor opened again, you would re-enter the safe mode due to script compile failure. Mine was complaining about missing NavMeshSurface

  • Anywhere you have reference to NavMeshSurface you would have something like using UnityEngine.AI but it has moved, so using the new using Unity.AI.Navigation; instead

Now it’s fine.
8685045--1171128--upload_2022-12-24_22-57-17.png

8 Likes

Thanks, this worked for me too. I guess that restarting fixed the issue.

Also, for anyone wondering, here is the installation guide:
https://docs.unity3d.com/Manual/NavMesh-BuildingComponents.html

1 Like

I got this error from the FPS Micrograme. It would appear they typed the namespace wrong. They had using UnityEngine.AI - which was greyed out indicating it was unused. So, I just replaced it with your suggestion and it fixed it.