SDK Getting Started

You can use an SDK to help implement AccelByte services in your game. The SDK acts as a bridge between your game and our services, making those services easy to access. There are two SDKs available for you to use as follows.

Download Unity SDKDownload UE4 SDK

Unity Getting Started Guide

To get started with Unity, you are required to install the Unity plugin either from package or source code.

Find the Package You've Downloaded

  1. Open the Unity editor, then open your project.
  2. Go to Assets > Import Package on the menu bar.
  3. Choose Custom Package.
  4. Search for the package you've downloaded.

Input the JSON Content into AccelByteSDKConfig.json

  1. Ensure that you have already created the AccelByteSDKConfig.json file.

  2. Input the required information into the fields listed below.

    {
    "ClientId":"<GAME_CLIENT_ID>",
    "ClientSecret":"<GAME_CLIENT_SECRET>",
    "UseSessionManagement": true,
    "PublisherNamespace":"<YOUR-PUBLISHER-NAMESPACE>",
    "Namespace":"<YOUR-GAME-NAMESPACE>",
    "BaseUrl": "<SERVER-BASE-URL>",
    "LoginServerUrl":"<AUTH-SERVER-URL>",
    "IamServerUrl":"<IAM-SERVER-URL>",
    "PlatformServerUrl":"<PLATFORM-SERVER-URL>",
    "BasicServerUrl":"<BASIC-SERVER-URL>",
    "LobbyServerUrl":"<LOBBY-SERVER-URL>",
    "TelemetryServerUrl":"<TELEMETRY-SERVER-URL>",
    "RedirectUri":"http://localhost",
    "CloudStorageServerUrl":"<CLOUDSTORAGE-SERVER-URL>",
    "GameProfileServerUrl":"<GAMEPROFILE-SERVER-URL>",
    "StatisticServerUrl": "<STATISTIC-SERVER-URL>"
    }
    note

    If your game will be released without a publisher, you’ll be able to do everything related to your game in the game namespace. You can leave PublisherNamespace in the config file empty or null.

Install the Unity Plugin from the Source Code

To get started, first you need to download the AccelByte repository. To do so, follow the steps below.

  1. Create a file named AccelByteSDKConfig.json.
  2. After you create the file, add it to the Assets\Resources directory.
  3. Input the required information into the appropriate fields.
  4. Copy the whole Assets/AccelByte folder from the repository and add it to your project in the Assets directory.

Install the Unity Plugin from the Package

Ensure that you have downloaded the Unity package before getting started.

  1. Find the package you've downloaded.
  2. Click the All button to select all of the components.
tip

You can exclude any API that you’re sure you won’t use, such as CloudStorage, Telemetry, etc. If you need these APIs at a later date, you’ll be able to import them without reinstalling the Unity plugin.

  1. Click Import and wait for the installation to finish.
  2. Go to Assets\Resources and search for a file named AccelByteSDKConfig.json, then input the required content into the appropriate fields.
  3. Your SDK is ready to use!

UE4 Getting Started Guide

Before getting started with the UE4 SDK, first download Visual Studio 2017 and download and install the Epic Games Launcher.

Install Visual Studio 2017

Select the following items:

  • Desktop Development with C++ workload
  • Game Development with C++ workload
  • Windows 8.1 and UCRT SDK optional component of the Game Development with C++ workload

install-desktop-dev-workload

install-game-dev-workload

Then, proceed with the installation as instructed.

Install Unreal Engine 4.18

Ensure that you’ve already installed the Epic Games Launcher before you begin.

  1. Open the Epic Games Launcher.
  2. Click Unreal Engine in the menu.

highlight-unreal-engine

  1. Open the Library menu at the top.

highlight-library

  1. Click the Plus symbol next to Engine Versions.

highlight-plus-button

  1. Change the version of Unreal Engine to install by choosing 4.18.3 from the dropdown menu, then install.

select-ue4-version

Integrate the AccelByte UE4 SDK with Your Game

  1. Create or open existing Unreal Engine 4 project.

  2. Copy the plugin folder Plugins/AccelByteUe4Sdk to your game's plugins folder.

  3. Add the plugin to your project files:

    • In /MyAwesomeGame.uproject

      "Plugins": [
      ...
      {
      "Name": "AccelByteUe4Sdk",
      "Enabled": true
      },
      ...
    • In /Source/MyAwesomeGame.Target.cs, and in /Source/MyAwesomeGameEditor.Target.cs

      ExtraModuleNames.AddRange(new string[]
      {
      ...
      "AccelByteUe4Sdk",
      ...
      }
    • In /Source/MyAwesomeGame/MyAwesomeGame.Build.cs

      PublicDependencyModuleNames.AddRange(
      new string[] {
      ...
      "AccelByteUe4Sdk",
      ...
      }
  4. Open the editor, click Edit then Project Settings.

    edit-project-settings

  5. To configure the SDK client credentials, scroll to the Plugins section, and open AccelByte Unreal Engine 4 Client SDK.

  6. Choose the desired settings then click Set as Default. The chosen settings will be saved to DefaultEngine.ini.

    settings-window

  7. To configure the SDK server credentials, scroll to the Plugins section and open AccelByte Unreal Engine 4 Server SDK.

  8. Choose the desired settings then click Set as Default. The chosen settings will be saved to DefaultEngine.ini.

    settings-window

  9. Include header files in your game. For example, if you want to use LobbyApi:

    #include "Core/AccelByteRegistry.h"
    #include "Api/AccelByteOauth2Api.h"
    #include "Api/AccelByteLobbyApi.h"
    void SLobbyWidget::Connect()
    {
    AccelByte::FRegistry::Lobby.Connect();
    }
    void SLobbyWidget::SendPartyChat(FString Message)
    {
    AccelByte::FRegistry::Lobby.SendPartyMessage(Message);
    }
  10. You are ready to go!

Plugin Usage

Here’s an example of how to use the SDK to create a new user profile. Note that you must be logged in before you can implement any backend services.

using AccelByte.Api;
using AccelByte.Models;
using AccelByte.Core;
class MainMenu
{
public void OnLoginClick(string email, string password)
{
var user = AccelBytePlugin.GetUser();
user.LoginWithUsername(email, password,
result =>
{
if (result.IsError)
{
Debug.Log("Login failed");
}
else
{
Debug.Log("Login successful");
}
});
}
public void OnCreateProfileClick()
{
var userProfiles = AccelBytePlugin.GetUserProfiles();
userProfiles.CreateUserProfile(
new CreateUserProfileRequest
{
language = "en",
timeZone = "Asia/Jakarta",
firstName = "John",
lastName = "Doe",
dateOfBirth = "2000-01-01"
},
result =>
{
if (result.IsError)
{
Debug.Log("Creating user profile failed");
}
else
{
Debug.Log("User profile created.");
Debug.Log("First Name: " + result.firstName);
Debug.Log("Last Name: " + result.lastName);
}
});
}
}

Debug Log

Our Unity SDK includes a debug log, which appears both in the Unity editor and on a player’s device. You can filter which types of messages are included in this log, or even disable the log altogether. Disabling the log can be useful if you release an update to your game that doesn’t involve AccelByte services.

The log is enabled by default. To disable it, open the AccelByteSDKConfig.json file and change the EnableDebugLog value to false. To enable the log again, just change this value back to true.

{
...
"UseSessionManagement": true,
"UsePlayerPrefs": false,
"EnableDebugLog": true,
"DebugLogFilter": "log",
}

You can also filter which messages are included in the log by defining the Log Type, as seen below.

Log TypeRemarks
LogThis is the default setting, used to display all log messages
WarningDisplay warning, assert, error, and exception log messages
AssertDisplay assert, error, and exception log messages
ErrorDisplay error and exception log messages
ExceptionDisplay exception log messages
{
...
"UseSessionManagement": true,
"UsePlayerPrefs": false,
"EnableDebugLog": true,
"DebugLogFilter": "log",
}

What's Next?

  • Learn how to implement our services in Unity using our sample game as your guide.