Class RelaySetup

Namespace
Unity.Multiplayer.Core

What Unity Relay join codes need, and what to say when something is missing (UM-T71). Engine-free: the runtime (RelayJoinCodeService), the drop-in front end and the editor's New Game wizard all ask it, so a developer reads the same sentence in a menu toast, the Console and the wizard.

public static class RelaySetup
Inheritance
RelaySetup
Inherited Members

Remarks

Relay needs three things: the com.unity.services.multiplayer package (PackageName), the Unity project linked to a Unity Cloud project (a cloud project id, which Unity bakes into every build), and Relay turned on for that Cloud project in the dashboard. Players sign in anonymously (Unity Authentication) and need no account.

Fields

DashboardUrl

Where a Cloud project is created and Relay is turned on.

public const string DashboardUrl = "https://cloud.unity.com/"

Field Value

string

DefaultEnvironment

The Unity Services environment every Cloud project has; used when none is set.

public const string DefaultEnvironment = "production"

Field Value

string

NotInstalledMessage

The package is missing.

public const string NotInstalledMessage = "Unity Relay join codes need the com.unity.services.multiplayer package (it defines MINDATTIC_UGS). Add it with MindAttic > Multiplayer > New Game... (step 3) or tools/link-unity-cloud.ps1, link the project to a Unity Cloud project with Relay on, or use the rendezvous service (NetConfig.RendezvousUrl) with a dedicated server."

Field Value

string

NotLinkedMessage

The project has no cloud project id.

public const string NotLinkedMessage = "Unity Relay isn't set up: this project isn't linked to a Unity Cloud project. In the editor open Edit > Project Settings > Services, pick the organization and the Cloud project and link it (or run tools/link-unity-cloud.ps1 with the project id), then turn on Relay for that project at https://cloud.unity.com/ and rebuild."

Field Value

string

PackageName

The package that brings Unity Relay (and defines MINDATTIC_UGS).

public const string PackageName = "com.unity.services.multiplayer"

Field Value

string

PackageVersion

The package version this library is verified against; the wizard and tools/link-unity-cloud.ps1 add it.

public const string PackageVersion = "2.4.1"

Field Value

string

RelayOffMessage

Relay answered that it is not enabled (or not allowed) for the linked Cloud project.

public const string RelayOffMessage = "Unity Relay refused the request: turn on Relay for the linked Cloud project at https://cloud.unity.com/ (Products > Relay) and check that the project id in Project Settings > Services is that project's."

Field Value

string

UnreachableMessage

Unity Gaming Services could not be reached.

public const string UnreachableMessage = "Could not reach Unity Gaming Services: check this computer's internet connection and try again."

Field Value

string

Methods

Check(bool, string)

Where a project stands: installed is whether the package is compiled in.

public static RelayReadiness Check(bool installed, string cloudProjectId)

Parameters

installed bool
cloudProjectId string

Returns

RelayReadiness

Describe(RelayReadiness)

One sentence for readiness: what is missing, or that Relay is set up.

public static string Describe(RelayReadiness readiness)

Parameters

readiness RelayReadiness

Returns

string

EnvironmentOrDefault(string)

environment trimmed, or DefaultEnvironment when it is empty.

public static string EnvironmentOrDefault(string environment)

Parameters

environment string

Returns

string

ExplainFailure(string, string, string, string)

A message to show for a Unity Services failure: the reason when it is one a developer can fix (not linked, Relay off, a missing environment, offline), else message itself. typeName is the exception's type name and reason its UGS reason or error code as text, when it has one.

public static string ExplainFailure(string typeName, string reason, string message, string environment)

Parameters

typeName string
reason string
message string
environment string

Returns

string

IsProjectId(string)

True when value looks like a Unity Cloud project id: a GUID, with or without dashes or braces. (Organization ids are free-form, so only the project id is checked.)

public static bool IsProjectId(string value)

Parameters

value string

Returns

bool