3. Start the app at boot
What starting does
Call McApp.StartAsync once, when the game starts, before the first menu. It does four things:
- Reads remote config and the version gate (section 7).
- Restores the player's saved session from an earlier launch.
- If nobody has played on this device before, signs the player in as a guest, so the game can start with no login screen.
- Turns on error reports (section 14).
Afterwards McApp.Player is the signed-in player, and McApp.Player.playerId is their id. Use that id as the player's user id everywhere: in your game API's tables, as the connection id on your game servers, and in leaderboards.
Call the client classes in this guide from Unity's main thread, and await them normally. They save the session in PlayerPrefs, which Unity allows only on the main thread.
The result
| Field | Meaning |
|---|---|
Ok |
A player is signed in |
Player |
The signed-in player |
IsNewPlayer |
This launch created the player: show a tutorial, ask for a name |
Offline |
MultiConnectCloud could not be reached. Config holds the last copy saved on this device |
Gate.updateRequired |
This build is older than the minimum you set: show an update screen with Gate.storeUrl |
Gate.maintenance |
Maintenance is on: show Gate.maintenanceMessage and Gate.maintenanceEndsAt |
Gate.notice |
Free text you set on the dashboard, shown however your game chooses |
Error |
Banned when the player is banned; UnknownKey when the SDK key is missing or wrong |
Script 3.1: A boot script
using MultiConnect.App;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameBoot : MonoBehaviour
{
private async void Start()
{
var start = await McApp.StartAsync();
if (start.Gate.updateRequired)
{
Debug.Log("Please update the game: " + start.Gate.storeUrl);
return;
}
if (start.Gate.maintenance)
{
Debug.Log("Maintenance: " + start.Gate.maintenanceMessage);
return;
}
if (start.Error == McAppError.Banned)
{
Debug.Log("This account is banned: " + start.Message);
return;
}
if (start.Offline)
Debug.Log("Playing offline; online features will retry.");
if (start.IsNewPlayer)
Debug.Log("Welcome, new player " + McApp.Player?.playerId);
SceneManager.LoadScene("MainScene");
}
}
Put Script 3.1 on an object in your first scene, and name your menu scene in place of MainScene.
Games that show a sign-in screen first: call McApp.StartAsync(signInAsGuest: false). A returning player is still signed in from their saved session. A new player is not, and Error is NotSignedIn, so you show your sign-in screen (section 5).
When the player changes: McApp.PlayerChanged is raised on sign-in, on switching account, on sign-out and on profile changes. It passes the new player, or null when nobody is signed in.

