Gamebase SDK for Unity 2.76.0 Toast Gamebase Platform

Loading...
Searching...
No Matches

## ◆ Initialize() [2/2]

static void Initialize | ( | GamebaseRequest.GamebaseConfiguration | configuration,
|  | GamebaseCallback.GamebaseDelegate< GamebaseResponse.Launching.LaunchingInfo > | callback )
| static

This function initialize the Gamebase SDK with Gamebase configuration.

If this function is not called, the Gamebase SDK function will not work.

Since
  Added 1.6.0

Parameters

  configuration | Settings for the Gamebase SDK.
  callback | The callback provided will return a LaunchingInfo object that contains the infomations of Gamebase.

Example Usage :

public void InitializeWithConfigurationSample(string appID, string appVersion)
{
var configuration = new GamebaseRequest.GamebaseConfiguration();
configuration.appID = appID;
configuration.appVersion = appVersion;
configuration.displayLanguageCode = GamebaseDisplayLanguageCode.English;
#if UNITY_ANDROID
configuration.storeCode = GamebaseStoreCode.GOOGLE;
#elif UNITY_IOS
configuration.storeCode = GamebaseStoreCode.APPSTORE;
#elif UNITY_WEBGL
configuration.storeCode = GamebaseStoreCode.WEBGL;
#elif UNITY_STANDALONE
configuration.storeCode = GamebaseStoreCode.WINDOWS;
#else
configuration.storeCode = GamebaseStoreCode.WINDOWS;
#endif
Gamebase.Initialize(configuration, (launchingInfo, error) =>
{
if (Gamebase.IsSuccess(error) == true)
{
Debug.Log("Initialization succeeded.");
//Following notices are registered in the Gamebase Console
var notice = launchingInfo.launching.notice;
if (notice != null)
{
if (string.IsNullOrEmpty(notice.message) == false)
{
Debug.Log(string.Format("title:{0}", notice.title));
Debug.Log(string.Format("message:{0}", notice.message));
Debug.Log(string.Format("url:{0}", notice.url));
}
}
//Status information of game app version set in the Gamebase Unity SDK initialization.
var status = launchingInfo.launching.status;
// Game status code (e.g. Under maintenance, Update is required, Service has been terminated)
// refer to GamebaseLaunchingStatus
if (status.code == GamebaseLaunchingStatus.IN_SERVICE)
{
// Service is now normally provided.
}
else
{
switch (status.code)
{
case GamebaseLaunchingStatus.RECOMMEND_UPDATE:
{
// Update is recommended.
break;
}
// ...
case GamebaseLaunchingStatus.INTERNAL_SERVER_ERROR:
{
// Error in internal server.
break;
}
}
}
}
else
{
// Check the error code and handle the error appropriately.
Debug.Log(string.Format("Initialization failed. error is {0}", error));
if (error.code == GamebaseErrorCode.LAUNCHING_UNREGISTERED_CLIENT)
{
GamebaseResponse.Launching.UpdateInfo updateInfo = GamebaseResponse.Launching.UpdateInfo.From(error);
if (updateInfo != null)
{
// Update is require.
}
}
}
});
}
Toast.Gamebase.Gamebase.Initialize
static void Initialize(GamebaseCallback.GamebaseDelegate< GamebaseResponse.Launching.LaunchingInfo > callback)
This function initialize the Gamebase SDK with inspector settings.
Definition Gamebase.cs:136
Toast.Gamebase.Gamebase.IsSuccess
static bool IsSuccess(GamebaseError error)
Return true if the GamebaseException object is null or the error code is zero.
Definition Gamebase.cs:57
Toast.Gamebase.Gamebase
The Gamebase class is core of Gamebase service.
Definition Gamebase.cs:11