Type Allocation and RelayServiceException for Relay are conflicting with Multiplayer Services

I am using Relay and Multiplayer Game Services. When creating a relay I am using the following code:

using UnityEngine;
using Unity.Services.Relay;
using Unity.Services.Relay.Models;


public class TestRelay : MonoBehaviour
{
    private async void CreateRelay()
    {
        try
        {
            Allocation allocation = await Relay.Instance.CreateAllocationAsync(3);

            string joinCode = await Relay.Instance.GetJoinCodeAsync(allocation.AllocationId);

        } catch(RelayServiceException e)
        {
            Debug.Log(e);
        }
    }
}

However I am getting the following errors:

Assets\Scripts\Network\TestRelay.cs(12,13): error CS0433: The type ‘Allocation’ exists in both ‘Unity.Services.Multiplayer, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ and ‘Unity.Services.Relay, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’

and

Assets\Scripts\Network\TestRelay.cs(16,17): error CS0433: The type ‘RelayServiceException’ exists in both ‘Unity.Services.Multiplayer, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ and ‘Unity.Services.Relay, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’

I am using Unity 6000.0.2.26f1 and Multiplayer Services 1.0.2 with Relay 1.0.5

The two packages are mutually exclusive. The Multiplayer Services package contains the Relay SDK as a namespace (along with the other multiplayer service standalone packages). You can use that namespace or you can use the new Sessions api.

see Migrating from the standalone SDKs to the Multiplayer SDK

Note there is an existing typo in the BuildClientRelayServerData code sample:

    hostConnectionData: joinAllocation.ConnectionData,

should be:

    hostConnectionData: joinAllocation.HostConnectionData,
1 Like