Unity Netcode Integration
Unity Netcode for GameObjects (NGO) is Unity's official networking solution. Universal Friend List supports NGO through the custom server implementation.
Prerequisites
Unity Netcode Requirements
- Unity Netcode for GameObjects package installed via Package Manager
- Basic NGO network setup complete
- Unity 2021.3 or newer
Install via Window → Package Manager → Unity Registry → Netcode for GameObjects
Configuration
Unity Netcode doesn't have a built-in friends system, so the custom server is required:
- Set Backend Type to
UnityNetcode - Set Use Native Implementation to
false - Configure server URLs (see Server Setup)
User ID for Unity Netcode
NGO provides a Client.LocalClientId but this is session-specific. For persistent friends, use your own authentication system:
// After authentication
var userId = myAuth.GetUserId();
friendInitializer.Initialize(userId);
Example: Simple Unity Netcode Connection
See Scripts/Examples/NetworkConnections/SimpleUnityNetcodeConnection.cs:
using Unity.Netcode;
using UnityEngine;
public class SimpleUnityNetcodeConnection : MonoBehaviour
{
public NetworkManager networkManager;
public void StartHost() {
NetworkManager.Singleton.StartHost();
}
public void StartClient() {
NetworkManager.Singleton.StartClient();
}
public override void OnClientConnected(ulong clientId) {
Debug.Log($"Client {clientId} connected");
// Use your auth user ID for friend system
}
}