Access
Connect cross-platform accounts & identity management
You can use AccelByte Cloud’s Unity SDK to integrate AccelByte Cloud services into your game. The Unity SDK acts as a bridge between your game and our services, making those services easy to access.
Before you start the steps in this guide:
NOTE
AccelByte Cloud currently supports Unity versions 2019.2 and 2019.4 upwards.
Follow the steps below to install the Unity SDK:
{
"Default": {
"Namespace": "Game Namespace",
"UsePlayerPrefs": true,
"EnableDebugLog": true,
"DebugLogFilter": "Log",
"BaseUrl": "https://demo.accelbyte.io",
"RedirectUri": "http://127.0.0.1",
"AppId": "",
"PublisherNamespace": "Publisher Namespace"
}
}
{
"Default": {
"Namespace": "Default",
"BaseUrl": "",
"RedirectUri": "http://127.0.0.1"
}
}
{
"Default": {
"ClientId": "<OAuth Client ID>",
"ClientSecret": "<OAuth Client Secret>"
}
}
NOTE
Leave the Client Secret empty if the Game Client uses Public Client Type (opens new window).
NOTE
Game servers use Confidential Client Type so you need to define the Client Secret.
The next steps will depend on your game.
Here’s an example of how to use AccelByte Cloud’s Unity SDK to create a new user profile.
You must be authorized 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<TokenData, OAuthError> 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);
}
});
}
}
AccelByte Cloud’s 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 in the build process to skip logs from the AccelByte services.
The debug 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.
{
...
"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 Type | Remarks |
---|---|
Log | This is the default setting, used to display all log messages |
Warning | Display warning, assert, error, and exception log messages |
Assert | Display assert, error, and exception log messages |
Error | Display error and exception log messages |
Exception | Display exception log messages |
Here’s an example of how to apply filtering messages based on the Log Type. You can make this change in AccelByteSDKConfig.json.
{
...
"UseSessionManagement": true,
"UsePlayerPrefs": false,
"EnableDebugLog": true,
"DebugLogFilter": "log",
…
}