Hey dudes
I’ve run into this specific issue where Unity does not recognize the new RelayServerData(allocation, “dtls”), when placed inside the ().SetRelayServerData().
If the image is not showing here is a link to it directly: Set-Relay-Server-Data-error hosted at ImgBB — ImgBB
It’s giving me the following error:
“There is no argument given that corresponds to the required formal parameter ‘port’ of ‘UnityTransport.SetRelayServerData(string, ushort, byte[ ], byte[ ], byte[ ], byte[ ], bool)’”
Here is my code for Creating a lobby:
public async void CreateLobby(string lobbyName, bool isPrivate)
{
try
{
joinedLobby = await LobbyService.Instance.CreateLobbyAsync(lobbyName, 4, new CreateLobbyOptions { IsPrivate = isPrivate });
Allocation allocation = await AllocateRelay();
string relayJoinCode = await GetRelayJoinCode(allocation);
NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(new RelayServerData(allocation, "dtls"));
NetworkManager.Singleton.StartHost();
lobbyBackground.SetActive(false);
lobbyList.SetActive(false);
}
catch (LobbyServiceException e)
{
Debug.Log(e);
}
}
Also here is the AllocateRelay() function that is referenced in the above code:
private async Task<Allocation> AllocateRelay()
{
try
{
Allocation allocation = await RelayService.Instance.CreateAllocationAsync(3);
return allocation;
}
catch (RelayServiceException e)
{
Debug.LogException(e);
return default;
}
}
What am I missing here?
I get the same error even when I just copy the example from Unity here:
https://docs.unity.com/ugs/en-us/manual/relay/manual/relay-and-ngo#Configur
I believe I have all needed references, such as these:
using Unity.Netcode.Transports.UTP;
using Unity.Networking.Transport;
using Unity.Networking.Transport.Relay;
using Unity.Services.Relay;
using Unity.Services.Relay.Models;
I’m using Unity 2021.3.7f1, with Relay version 1.0.5 and Lobby version 1.0.3.
Any help would be greatly appreciated!
Sorry if this is unclear, I’ve never used the forum before.