How would I fix "Unity.Netcode" Namespace not apearing after installing Netcode for Gameobjects?

Hello! I am reletively new to Unity and I am trying to convert a single-player game into a multi-player game using Netcode for Gameobjects. However, after installing the Netcode for Gameobjects package in the editor (I have tried two versions of the editor “2021.3.16f1” and “2022.3.0f1”, and three versions of Netcode for Gameobjects “1.1.0”, “1.2.0”, and “1.4.0”), I tried to use the “NetworkBehavior” class in my scripts, but when I try and add “using Unity.Netcode” to the top of the script so that I can use that class, it is underlined in red and says that that namespace does not exist.

I have tried:

  • Looking through the forums, which lead me to attempt to rebuild the project files with Edit>Preferences>External Tools>Git Packages enabled, then I tried again with Registry Packages enabled as well. Neither worked.
  • Adding the .dll file to the References in the Visual Studio Solution Explorer. When I attempted this, I could find the “Unity.Netcode.Editor.dll”, “Unity.Netcode.Runtime.dll”, “Unity.Netcode.Components.dll”, and a few others, but I could not find the plain “Unity.Netcode.dll”.

I am using:

  • Unity Editor version: 2022.3.0f1 (LTS)
  • Microsoft Visual Studio 2022 (v2.0.18 (I think))
  • Netcode for Gameobjects version: 1.4.0

Any help is usefull, I hope I was clear enough.

Try inporting Netcode into a new project to see if you have the same issue.

In any case, one does not manually add using statements anymore these days. The IDE does that for you with a simple action after you wrote a valid statement (such as subclassing NetworkBehaviour) where the Type exists but is just missing the right import in the current file. The IDE should also add the necessary dependencies to the assembly definition file, if any.

But … I cannot speak for VS. I would expect it to add usings but I would not be surprised that it still lacks essential Unity workflow features such as adding dependencies to asmdefs. If you use an asmdef make sure to add the Netcode dependency manually.

1 Like

Hi @wpeoif0 , that’s not how you reference assemblies in Unity (never do that!). The right way to do it is to reference the dll / package in the Assembly Definition File (asmdf) where the script you want to allow to use NGO’s features is placed.

This page has a lot of info and screenshots on the topic, I’d recommend to read it first.

Does this help?

1 Like

Thank you! This was very helpfull.

1 Like