Skip to main content
Getting Started

Not translated yet — showing English.

Connect Your Game

Three things connect a Unity game to PlayServ: the SDK package, a client key, and one call to PlayServ.Connect(). The client key says which project and environment the game belongs to; the SDK does the rest, from signing in the player to keeping the connection alive.


Before you start

You needWhere to get it
Unity 2021.3 or newer—
A PlayServ projectCreate a Project
A client key (pk_…)Projects → your project's API keys → Create key, type Client. The key belongs to the environment selected in the top bar. See API Key Management.

Install the SDK

The SDK is the com.playserv.sdk package. Install it from OpenUPM, or from its Git repository.

Add the OpenUPM registry

In Unity, open Edit ▸ Project Settings ▸ Package Manager and add a scoped registry:

FieldValue
NameOpenUPM
URLhttps://package.openupm.com
Scope(s)com.playserv.sdk

Add the package

Open Window ▸ Package Manager, choose Add package by name, and enter com.playserv.sdk with the version you want. Use an exact version, so every machine and build gets the same SDK.

To install from Git instead, choose Add package from git URL and enter https://github.com/playserv1/playserv-unity-sdk.git#<version>.

The SDK's optional add-ons, such as sign-in with Apple, Google, Facebook, Epic or Steam, are companion packages. Install, remove and switch them on in Tools ▸ PlayServ ▸ Settings, under the SDK module settings.


Configure the SDK

Open the PlayServ window

Choose Tools ▸ PlayServ ▸ Settings. The configuration is under Control Room, in PlayServ Config.

Choose the platform

Set Environment to Prod, the PlayServ platform your game connects to.

Paste the client key

Paste your pk_… key into Client Token, and set Game Version to your build's version.

Environment here is not your project's environment

Environment in the PlayServ window picks the PlayServ platform: always use Prod. Your project's environment, such as dev or prod, comes from the client key you paste: use a key of the environment the build should talk to.

FieldWhat it is
EnvironmentThe PlayServ platform. Use Prod.
Client TokenYour client key. It is built into the game.
Server TokenA server key for editor tools, such as deploying functions. It stays in the editor and never goes into a build.
Game VersionYour build's version, sent when the game connects.

The keys are kept in your local editor settings, not in the project's files. For CI builds, pass the key with the PLAYSERV_CLIENT_TOKEN environment variable and set PLAYSERV_ENVIRONMENT=Prod.


Connect for the first time

Add a script like this to your first scene:

using System;
using Playserv.Wrapper;
using UnityEngine;

public sealed class PlayServBootstrap : MonoBehaviour
{
    async void Start()
    {
        try
        {
            bool online = await PlayServ.Connect();
            Debug.Log(online ? $"Online as {PlayServAuth.PlayerId}" : "PlayServ connect failed");
        }
        catch (Exception e)   // for example, a client key that isn't valid
        {
            Debug.LogError($"PlayServ sign-in failed: {e.Message}");
        }
    }

    void OnDestroy() => PlayServ.Disconnect();
}

Press Play. The Console shows Online as plr_…: the game is connected, signed in as an anonymous player. That player now appears in Players, in the environment of your key.

What Connect() does, and how the connection is kept alive, is in Connection & Session.


Upgrade from an older SDK

The SDK's API changed across releases. Tools ▸ PlayServ ▸ Migrate Project scans your scripts for the old calls, shows the changes, and applies the ones you select; it keeps backups of the files it edits.

Game ID and user ID are no longer needed

Since version 0.5, the client key identifies the project and environment, and the player comes from their session. Remove a Game ID or user ID from your code by hand; Migrate Project doesn't do it. Leave Deployment Game Id in the PlayServ window empty: when it's set, the SDK keeps players apart from the ones saved without it.


If it doesn't connect

What you seeCheck
Connect() throws an exception when signing inThe client key: paste it again, and make sure it hasn't been revoked.
Connect() returns false with error 00001The connection was refused: check the client key, the SDK version and Game Version.
The game connects, but your data is missingThe key's environment: it may be a key of another environment.
"Endpoint is required"When configuring from code, set BackendServerAddress, see What the SDK needs.
Old calls such as PlayServ.Ready don't compileRun Migrate Project.

Next steps

Last updated on 19 Oct 2026