Skip to main content

Install the Unity SDK

Last updated on September 11, 2023

Overview

Use the AccelByte Gaming Services (AGS) Game SDK for Unity to implement AGS features in your game.

AGS Unity SDK on GitHub

Prerequisites

  • Unity version 2019.2 or newer
  • Create a Game Namespace
  • Create an IAM Client
  • Get the Client ID
AGS Starter

AGS Starter currently supports Unity versions 2019.2 and 2019.4 upwards.

Also, make sure that you use the following format for the BaseUrl, otherwise your API calls may return an error due to a domain mismatch:

https://<Game TitleID>.<environment name>.gamingservices.accelbyte.io
  • Use the dev value when you're working on a development environment. For example: https://spaceshooter.dev.gamingservices.accelbyte.io
  • Use the prod value when you're ready to launch to a live environment. For example: https://spaceshooter.prod.gamingservices.accelbyte.io

Tutorial

NOTE

You must install and configure Git on your computer so that Unity can use a UPM Package.

Install and configure

Learn how to download and install the AGS Game SDK for Unity and set up your AGS configuration file.

AGS Starter

In Starter tier, you can download and save the configuration file for Unity.

You can download the configuration files in the Starter tier dashboard during set up. Later, you can also download them from the OAuth Clients page in the AGS Admin Portal.

AGS Premium does not yet have the configuration file download option.

  1. Open your Unity Project.

  2. Go to Window > Package Manager > + > Add package from git URL, paste https://github.com/AccelByte/accelbyte-unity-sdk.git into the pop-up, and click Add.

    NOTE

    Ensure that you download the latest version.

    If you are using Assembly Definitions in your project, you may need to add the com.accelbyte.UnitySDK assembly as a reference.

  3. Configure the SDK

    There are two ways to configure the SDK in your project. You can use our editor tool or manually create and modify the configuration files.

    a. Configure the SDK using the Editor tool: Go to AccelByte > Edit Settings in the menu bar. Fill in Namespace,Base Url, Client Id, Client Secret, Redirect Uri, and App Id. Leave the other fields empty and click Save.

    After you do this, the system will generate and auto populate the AccelByteSDKConfig.json, AccelByteSDKOAuthConfig.json and AccelByteServerSDKOAuthConfig.json files in your Assets/Resources folder.

    To modify the configuration files manually, follow the step for option b, below.

    using the editor

    b. Create Config Files Manually: Create a file called AccelByteSDKConfig.json in your Assets/Resources folder and fill it with the appropriate information in the following format:

    NOTE

    Leave the Publisher namespace parameter empty.

    {
    "Default":
    {

    "Namespace": "Game Namespace",
    "UsePlayerPrefs": true,
    "EnableDebugLog": true,
    "DebugLogFilter": "Log",
    "BaseUrl": "<baseURL>",
    "RedirectUri": "http://127.0.0.1",
    "AppId": "",
    "PublisherNamespace": ""
    }
    }
    NOTE

    You can find your ClientID, Secret, and Namespace settings in the AGS Admin Portal or refer to the Access documentation for more information.

    Contact support or your Account Manager if you're unsure of your API URLs. If you're in AGS Starter, the development env's base URL is https://dev.gamingservices.accelbyte.io and the production env's base URL is https://prod.gamingservices.accelbyte.io.

    Next, create two files and name them AccelByteSDKOAuthConfig.json and AccelByteServerSDKOAuthConfig.json. Add both files to your project in the Assets/Resources directory; their contents should be as follows:

    {
    "Default":
    {
    "ClientId": "<OAuth Client ID>",
    "ClientSecret": "<OAuth Client Secret>"
    }
    }
NOTE

Leave the Client Secret empty if the Game Client uses the Public Client type.

Congratulations! You successfully configured the AGS SDK for Unity.