A UnityTransport implementation for Fish-Net.
If you have further questions, come find me as ooonush
in the FirstGearGames Discord!
The FishyUnityTransport library API is close to UnityTransport for NGO and uses some of its code.
Make sure you have the following packages installed:
- UnityTransport 1.3.1 or newer
- Fish-Net
-
Install Fish-Net from the official repo or Asset Store.
-
Install UnityTransport package.
-
Install FishyUnityTransport unitypackage from the release section or using the Git URL:
https://github.com/ooonush/FishyUnityTransport.git?path=Assets/FishNet/Plugins/FishyUnityTransport
-
Add the "FishyUnityTransport" component to your "NetworkManager".
This library supports Unity Relay, and since its API is similar to the UnityTransport for NGO API, I recommend reading the official Relay documentation.
I also recommend you read the Relay section in NGO docs.
[SerializeField] private NetworkManager _networkManager;
public async Task StartHost()
{
var utp = (FishyUnityTransport)_networkManager.TransportManager.Transport;
// Setup HostAllocation
Allocation hostAllocation = await RelayService.Instance.CreateAllocationAsync(4);
utp.SetRelayServerData(new RelayServerData(hostAllocation, "dtls"));
// Start Server Connection
_networkManager.ServerManager.StartConnection();
// Start Client Connection
_networkManager.ClientManager.StartConnection();
}
public async Task StartClient(string joinCode)
{
JoinAllocation joinAllocation = await RelayService.Instance.JoinAllocationAsync(joinCode);
utp.SetRelayServerData(new RelayServerData(joinAllocation, "dtls"));
// Start Client Connection
_networkManager.ClientManager.StartConnection();
}