| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A Netick integration for Unity Transport and Unity Relay, featuring multi-protocol support and cross-platform connectivity. This package enables players from WebGL, mobile, and native platforms to connect to the same server instance using UDP, WebSocket, or Unity's Relay service.
This package requires Netick 2 and can be installed via Unity Package Manager using Git URLs.
Dependencies:
All dependencies can be installed via Unity Package Manager using Git URLs. For detailed instructions on installing packages from Git repositories, see the Unity documentation on installing from a Git URL.
Quick Installation Steps:
After installation, create a transport provider instance:
The transport supports four distinct protocol types:
The transport can simultaneously host multiple protocols on a single server instance, enabling cross-platform connectivity between WebGL clients and native applications.
Port Allocation Logic:
When multiple protocols are enabled, ports are automatically allocated sequentially:
firstProtocol = 7777 secondProtocol = 7777 + 1 thirdProtocol = 7777 + 2
Example Configuration:
This automatic allocation ensures no port conflicts when running multiple protocols simultaneously.
Optional encryption can be enabled for enhanced security:
Note: Secure connections require additional configuration and certificate management. Refer to Unity's networking documentation for certificate setup procedures.
Unity Relay provides NAT traversal and relay services, enabling players behind restrictive firewalls to connect. The transport includes built-in Relay support through Unity's Multiplayer Services SDK.
Installing Multiplayer Services Package:
Note: The older Relay SDK has been deprecated. Use the Multiplayer Services package instead.
Scripting Define Symbol:
After installing the package, add MULTIPLAYER_SERVICES_SDK_INSTALLED to your project's scripting define symbols:
Configure the transport to use Relay services:
Before launching Netick as a host, initialize the Relay allocation:
using Unity.Services.Relay;
using Unity.Services.Relay.Models;
public async void StartHost()
{
int maxPlayers = 10;
// Create relay allocation
Allocation hostAllocation = await RelayService.Instance.CreateAllocationAsync(maxPlayers);
NetickUnityTransport.SetAllocation(hostAllocation);
// Generate join code for clients
string joinCode = await RelayService.Instance.GetJoinCodeAsync(hostAllocation.AllocationId);
// Display or share the join code with clients
Debug.Log($"Join Code: {joinCode}");
// Start Netick as host
Network.StartAsHost(transportRelay, 0, sandboxPrefab);
}Workflow:
Clients use the host's join code to establish Relay connections:
using Unity.Services.Relay;
using Unity.Services.Relay.Models;
public async void JoinHost(string joinCode)
{
// Join relay allocation using host's code
JoinAllocation playerAllocation = await RelayService.Instance.JoinAllocationAsync(joinCode);
NetickUnityTransport.SetJoinAllocation(playerAllocation);
// Start Netick as client
NetworkSandbox sandbox = Network.StartAsClient(transportRelay, 0, sandboxPrefab);
// Connect to host (address parameter ignored when using Relay)
sandbox.Connect(0, "0.0.0.0");
}Workflow:
Important: When using Relay, the address parameter in Connect() is ignored. Connection routing is handled automatically through the Relay service using the join allocation.
The NetworkConnectionRequest data buffer (byte[]) has a fixed size of 200 bytes to avoid garbage collection at runtime.
Usage Considerations:
public override void OnConnectRequest(NetworkSandbox sandbox, NetworkConnectionRequest request)
{
// Use request.DataLength to determine actual data size
int actualDataLength = request.DataLength;
// Process only the relevant portion of the data
byte[] relevantData = new byte[actualDataLength];
Array.Copy(request.Data, relevantData, actualDataLength);
// Or manually resize the array for your use case
// byte[] customData = new byte[actualDataLength];
// Buffer.BlockCopy(request.Data, 0, customData, 0, actualDataLength);
}For Netick-related questions: Netick Discord Server
For Unity Transport Documentation: UTP Documentation
For Unity Relay documentation: Unity Relay Services
| Back | FazBrowse Home | New Git URL |