The purpose of this tutorial is to test the Netcode packet and any errors that may occur.
This first tutorial only covers the functionality of the packet without implementations of sending data between client and server.
I used the newest version of Unity Hub version 3.3.0 and Unity version 2021.3.9f1.
here and here.
Here are the steps taken in brief:
I created a folder for my projects called Unity3DProjects and I set it for each new project.
I created a new project using Unity Hub called Netcode001.
After creation, the Unity 3D editor will open and if there are problems with the license, then you will have to download the license from your Unity 3D account or obtain/activate a new one.
I use a free Personal Edition license renewed and reactivated on Wed, Dec 20, 2017, my old license when I started working with Unity was around 2013.
These things are important for the learning part because the development of the Unity 3D game engine had substantial changes and a lot of bugs. That’s why not all tutorials cover all the issues needed to develop a game and some elements are still in the development process.
Another element you have to take care of is the interaction with the Visual Studio Community, I received errors when changing the version from 2019 to the new version 2022. The generation of build errors sent me to a new empty folder and I fixed it by reopening the project again without Visual Studio, obviously after it has already been set in the Unity 3D editor.
The setting is made from the File – Preferences menu
The installation of the Netcode package is done from the main menu: Window – Package Manager:
Click the plus sign Add in the Package Manager status bar and select Add package by name… and fill with:
Wait for the package to be installed.
Using the right-click in the Hierarchy tab of the main Unity Window.
Select Create Empty and rename the GameObject with NetworkManager.
With this Unity game object, use click to Add Component in the Inspector Tab.
Search and select Netcode from the list shown.
Select NetworkManager Component from the list displayed and inside the NetworkManager component tab, locate the NetworkTransport field, and add these two scripts.
You need to check if the Select Transport is on the Select UnityTransport.
You can see also my scene has some new objects like a plane and a new game object named NetworkCommandLine.
You can add these two game objects, the plane at the root of the hierarchy and the NetworkCommandLine at the NetworkManager game object.
On the NetworkCommandLine game object use Add Component in the Inspector Tab to add a new C# script named NetworkCommandLine, see the source code:
public class NetworkCommandLine: MonoBehaviour
private NetworkManager netManager;
netManager = GetComponentInParent<NetworkManager>();
if (Application.isEditor) return;
var args = GetCommandlineArgs();
if (args.TryGetValue("-mlapi", out string mlapiValue))
private Dictionary<string, string> GetCommandlineArgs()
Dictionary<string, string> argDictionary = new Dictionary<string, string>();
var args = System.Environment.GetCommandLineArgs();
for (int i = 0; i < args.Length; ++i)
var arg = args[i].ToLower();
var value = i < args.Length - 1 ? args[i + 1].ToLower() : null;
value = (value?.StartsWith("-") ?? false) ? null : value;
Save this scene with a name into your folder project.
Use the main menu File – Build Settings… to build into executable into your project folder.
According to the second tutorial, you can test like a client or server with or not logging process.
Netcode001.exe -mlapi server
Netcode001.exe -mlapi client
Netcode001.exe -mlapi server & Netcode001.exe -mlapi client
If you use a text editor you can see all logging processes and steps.
You can see I have an old computer …
Version: Direct3D 11.0 [level 11.0]
Renderer: NVIDIA GeForce GTS 450 (ID=0xdc4)
VRAM: 468 MB
Begin MonoManager ReloadAssembly
- Completed reload, in 0.404 seconds
<RI> Initializing input.
<RI> Input initialized.
<RI> Initialized touch support.
Direct3D: detected that using refresh rate causes time drift. Will stop trusting refresh rate until the game window is moved.
Direct3D: detected that vsync is broken (it does not limit frame rate properly). Delta time will now be calculated using cpu-side time stampling until the game window is moved.
UnloadTime: 1.248400 ms
Setting up 1 worker threads for Enlighten.
[ALLOC_TEMP_TLS] TLS Allocator
Peak usage frame count: [1.0 KB-2.0 KB]: 31 frames, [2.0 KB-4.0 KB]: 167 frames, [2.0 MB-4.0 MB]: 1 frames
Initial Block Size 4.0 MB
Current Block Size 4.0 MB
Peak Allocated Bytes 2.1 MB
Overflow Count 0
Initial Block Size 64.0 KB
Current Block Size 64.0 KB
Peak Allocated Bytes 207 B
Overflow Count 0
Initial Block Size 256.0 KB
Current Block Size 256.0 KB
Peak Allocated Bytes 27.2 KB
Overflow Count 4
[ALLOC_TEMP_Background Job.Worker 8]
Initial Block Size 32.0 KB
Current Block Size 32.0 KB
Peak Allocated Bytes 54 B
Overflow Count 0