Get started

Install Cloud Save SDK

You can install the Package through the Unity Editor.

Navigate to Window > Package Manager and select Unity Registry from the Packages dropdown on the top left. You can either:

  • Search for Cloud Save in the search bar on the top right.
  • Add the package by name:
    • Open the dropdown indicated by +
    • Select "Add package by name..."
    • Enter the the package name "com.unity.services.cloudsave" (version is optional)

Note: The SDK includes code in Samples that shows how to read and write data and files using Cloud Save.

After installation the Cloud Save SDK is available from the Unity.Services.CloudSave namespace:

using Unity.Services.CloudSave;

Install Authentication SDK

The Cloud Save package relies on the Authentication package. The Unity Authentication service creates an account to persist player scores where you can use anoynymous sign-in or platform-specific authentication.

The Authentication package is installed as a dependency when you install the Cloud Save package. For information on installing packages manually, refer to Install a package from a registry.

After installation the Authentication SDK is available in Unity scripts from the Unity.Services.Authentication namespace:

using Unity.Services.Authentication;

Once installed, the Authentication package prompts you to link your Unity project to a Unity Game Services Project ID.

If your project is not linked to a UGS Project ID, or if you want to check what UGS Project ID it is linked to, you can follow these steps to manually link your Unity project to a UGS Project ID:

  • In the Unity Editor, select Edit > Project Settings....
  • Select Services,
    • Sign in if you have an Unity ID.
    • Otherwise, select Create a Unity ID.
  • Select your project.
  • Select Link.

Call the Cloud Save SDK

You must initialize the Cloud Save SDK and its dependencies in a lifecycle callback before use.

This is done by initializing all installed services via the Core SDK by calling await UnityServices.InitializeAsync() from the Unity.Services.Core namespace.

After the SDK initialization is complete, the player is authenticated. The following example uses anonymous authentication to create an anonymous player account. Other methods of authentication are available as outlined in the Unity Authentication documentation.

using System.Collections.Generic;
using Unity.Services.Authentication;
using Unity.Services.CloudSave;
using Unity.Services.CloudSave.Models;
using Unity.Services.Core;
using UnityEngine;

public class CloudSaveSample : MonoBehaviour
{
    private async void Awake()
    {
        await UnityServices.InitializeAsync();
        await AuthenticationService.Instance.SignInAnonymouslyAsync();
        SaveData();
    }

    public async void SaveData()
    {
        var playerData = new Dictionary<string, object>{
          {"firstKeyName", "a text value"},
          {"secondKeyName", 123}
        };
        var result = await CloudSaveService.Instance.Data.Player.SaveAsync(playerData);
        Debug.Log($"Saved data {string.Join(',', playerData)}");
    }
}

For more examples of how to use the Cloud Save SDK with Unity, refer to the Unity SDK tutorial.

Cloud Save REST API

You can access data in Cloud Save using the REST API.

REST APIs provide more flexibility and allow you to automate your workflows by using your favorite language and game development engine or from a game server.

The Cloud Save service provides the following REST APIs:

The REST API tutorial has information on how to create a token and call the REST API.

Additional resources