Unity SDK 7.1.0
12 days ago by Nikola Zagorchev
The Leanplum Unity SDK 7.1.0 uses the CleverTap Unity SDK 5.2.0 which enables CleverTap Variables to be defined and synced from the Unity Editor.
Using CleverTap SDK in Unity Editor from Leanplum Unity SDK
The Leanplum Unity SDK does not initialize the CleverTap SDK in the Unity Editor.
This is only done on mobile platforms by the native mobile SDKs during CleverTap Migration.
If you want to use the CleverTap Unity SDK inside the Unity Editor, for example, to define and sync Variables to the CleverTap Dashboard, follow these steps:
- Launch the CleverTap SDK
Call the CleverTapLaunchWithCredentials
orLaunchWithCredentialsForRegion
method.
Run this code for Unity Editor only.
Use the credentials of the CleverTap Account/Dashboard you want to connect to. Use the ones you are migrating to.
#if UNITY_EDITOR
string accountId = "YOUR_CLEVERTAP_ACCOUNT_ID";
string accountToken = "YOUR_CLEVERTAP_ACCOUNT_TOKEN";
string accountRegion = "YOUR_CLEVERTAP_REGION";
CleverTap.LaunchWithCredentialsForRegion(accountId, accountToken, accountRegion);
// You can also use CleverTap.LaunchWithCredentials(accountId, accountToken)
#endif
- Call the CleverTap methods you need directly. Do this outside the
Leanplum.CleverTapInstanceReady
, which you would use normally for migration. You can write a method which does that depending on the platform, for example:
private void CallCleverTap(Action action)
{
#if !UNITY_EDITOR
Leanplum.CleverTapInstanceReady += () =>
{
action();
};
#else
action();
#endif
}
- Usage:
CallCleverTap(() =>
{
CleverTap.FetchVariables((success) =>
{
Debug.Log($"CleverTap_FetchVariables: {success}");
});
});
CallCleverTap(() =>
{
CleverTap.SyncVariables(true);
});
- Play the game in the Editor