Migration
Migration Guide: 1.4.x / 1.5.x โ 1.6.xโ
This document describes the breaking changes and recommended migration steps when updating from versions 1.4.x / 1.5.x to 1.6.x of the SDK.
0. Migration Instructions for Plugin Files (Unity Project)โ
Before applying code-level changes, you must correctly migrate plugin files inside the Unity project.
Step-by-step instructions:โ
Close the Unity Editor
- Ensure that the editor is fully shut down before modifying files.
Clean old plugin files
- Delete all folders and files inside:
Assets/Platform101XP - Except the following folders, which should be kept:
Assets/Platform101XP/EditorAssets/Platform101XP/iOSConfigAssets/Platform101XP/AndroidConfig
- Delete all folders and files inside:
Review Unity build configuration files
- The plugin uses only its own custom
AndroidManifest.xmllocated in:Assets/Plugins/Android/AndroidManifest.xml - The plugin does not currently use any other custom Unity Android build configuration files (Gradle templates, ProGuard files, etc.).
- If your project uses custom Gradle templates or other build configuration overrides, verify that they do not contain old 101XP plugin content.
If such leftover content exists, remove it manually.
- The plugin uses only its own custom
Optional cleanup
- You may delete the entire folders:
Assets/Plugins/AndroidAssets/Plugins/iOS
- (Unity will recreate necessary folders or the plugin will reimport them.)
- You may delete the entire folders:
Re-import the plugin
- Reopen the Unity Editor.
- Import the new version of the plugin (1.6.x).
- After import, reapply plugin settings:
Window โ P101XP โ Settings โ Apply
1. Overview of Breaking Changesโ
1.1. Data member naming convention changedโ
- Fields previously in
snake_caseare nowcamelCase. - Several fields were renamed entirely (not only case-converted).
1.2. Event payload structures changedโ
AuthorizeResult and AccountResult were redesigned in 1.6.x.
1.3. New runtime access methodsโ
Authorization and account state is now accessed via:
public Token GetToken();
public Account GetAccount();
1.4. Namespaces Update (NEW in 1.6.x)โ
In versions 1.4.x / 1.5.x, data classes had no namespace and lived in Unityโs default namespace.
Starting from 1.6.x, all data classes were moved into:
namespace Platform101XP.Entities
Migration requirementโ
Add this line to all C# files where these SDK classes are used:
using Platform101XP.Entities;
This applies to:
AuthorizeResultTokenAccountResultAccount- Other SDK data classes
If your project relied on implicit default namespace resolution, compilation errors will occur until this using directive is added.
2. Data Member Renamingโ
2.1. General Naming Convention Changeโ
All (or most) data classes that previously used snake_case members now use camelCase.
For example (generic pattern):
access_tokenโaccessTokenuser_nameโuserNameuser_photo_urlโuserPhotoUrl
When migrating, please update all your code that directly accesses these fields to use camelCase.
2.2. Specific Renamed Membersโ
In addition to the case change, some members were explicitly renamed:
| Old name | New name |
|---|---|
error_message | error |
is_initialized | initialized |
is_invited | invited |
Please update all references to these fields accordingly.
3. Authorization Result Changesโ
3.1. Event Signatureโ
The authorization event keeps the same delegate type and event name:
public delegate void ResultOfAuthorize(AuthorizeResult authorizeResult);
public event ResultOfAuthorize AuthorizeResultEvent;
However, the AuthorizeResult structure has changed.
3.2. Old AuthorizeResult (โค1.5.x)โ
public class AuthorizeResult
{
public string access_token;
public long expires;
public string type;
public string provider;
public bool is_guest;
public string error_message;
}
3.3. New AuthorizeResult (1.6.x)โ
public class AuthorizeResult
{
public Token token;
public string error;
}
Where Token is defined as:
public class Token
{
public string accessToken;
public long expires;
public string type;
public string provider;
}
3.3.1. Key Changesโ
Token fields moved into a nested
Tokenclass- Previously:
access_token,expires,type,providerdirectly onAuthorizeResult. - Now: wrapped inside
AuthorizeResult.tokenof typeToken.
- Previously:
Error field renamed
error_messageโerror.
Guest flag removed
is_guestwas removed fromAuthorizeResult.- Guest status is now determined via account information (see section 4).
3.4. Migration Exampleโ
Before (โค1.5.x):
void OnAuthorize(AuthorizeResult result)
{
if (!string.IsNullOrEmpty(result.error_message))
{
// handle error
return;
}
if (result.is_guest)
{
// guest flow
}
else
{
// logged-in user flow
}
var token = result.access_token;
}
After (1.6.x):
void OnAuthorize(AuthorizeResult result)
{
if (!string.IsNullOrEmpty(result.error))
{
// handle error
return;
}
// Token object with camelCase members
Token token = result.token;
if (token == null)
{
// handle unexpected missing token
return;
}
// Guest / login status is now handled via Account (see section 5)
}
4. Account Result & Event Changesโ
4.1. Event Signatureโ
The account-related event keeps the same delegate type and name:
public delegate void ResultOfGettingAccount(AccountResult result);
public event ResultOfGettingAccount GetAccountEvent;
The payload type is now AccountResult with the following structure:
public class AccountResult
{
public Account account;
public string error;
}
Where Account is:
public class Account
{
public long accountId;
public long portalId;
public long userGameId;
public long mobileId;
public string userName;
public string userPhotoUrl;
public bool isGuest;
}
4.2. Guest and Login Statusโ
The guest flag is now located in the Account object:
- Use
Account.isGuestto check whether the user is a guest. - Use
Accountpresence (nullvs non-null) to determine if account information is available.
Example:
void OnAccountReceived(AccountResult result)
{
if (!string.IsNullOrEmpty(result.error))
{
// handle error
return;
}
var account = result.account;
if (account == null)
{
// account info not available yet or failed to load
return;
}
bool isGuest = account.isGuest;
// use account.accountId, account.userName, etc.
}
5. New Runtime Methods: GetToken() and GetAccount()โ
To simplify checking the current authorization state, version 1.6.x introduces:
public Token GetToken();
public Account GetAccount();
5.1. Return Valuesโ
Both methods return
nullif the user is not authorized at all, including cases where:- The user is not logged in.
- The user does not even have a guest session.
If the user is authorized as guest or a normal user:
GetToken()will eventually return a validToken.GetAccount()will eventually return a validAccount(withisGuestindicating guest vs regular user).
5.2. Timing & Synchronizationโ
Token and account information are fetched via two separate requests inside the SDK:
- Token information usually appears earlier.
- Account information may be available later.
This means:
- If
GetToken()returns a non-nullvalue, it does not necessarily mean thatGetAccount()will immediately return a non-nullvalue. - Your code should handle the possibility that token is ready while account is still loading.
5.3. Recommended Usageโ
- Initial state check:
var token = sdk.GetToken();
var account = sdk.GetAccount();
bool isAuthorized = token != null;
bool hasAccount = account != null;
bool isGuest = account != null && account.isGuest;
- Reacting to asynchronous updates:
Use the events to be notified when data becomes available:
AuthorizeResultEventโ triggered when token-related authorization completes.GetAccountEventโ triggered when account information is obtained.
Example:
sdk.AuthorizeResultEvent += OnAuthorize;
sdk.GetAccountEvent += OnAccountReceived;
This pattern lets you:
- Use
GetToken()/GetAccount()for polling / immediate checks. - Use events for synchronizing with the moment when the SDK actually receives the data.
6. Migration Checklistโ
When upgrading from 1.4.x / 1.5.x to 1.6.x, make sure to:
Update naming for all data members:
Change
snake_casefields tocamelCasewhere applicable.Apply explicit renames:
error_messageโerroris_initializedโinitializedis_invitedโinvited
Update authorization handling:
- Replace direct usage of
AuthorizeResult.access_token,expires,type,providerwithAuthorizeResult.token.accessToken,token.expires, etc. - Replace
error_messagewitherror. - Remove usage of
is_guestonAuthorizeResultand migrate toAccount.isGuest.
- Replace direct usage of
Update account handling:
- Adjust handlers for
GetAccountEventto accept the newAccountResultstructure. - Use
AccountResult.errorinstead of any previous error field. - Use
Account.isGuestto distinguish guest vs logged-in users.
- Adjust handlers for
Use new helper methods where appropriate:
- Use
GetToken()andGetAccount()to check current state instead of relying only on events or old APIs. - Handle the fact that
GetToken()may become available earlier thanGetAccount().
- Use
Test guest and logged-in flows:
Verify behavior for:
- Completely unauthorized user.
- Guest user.
- Fully logged-in user.
Confirm you correctly handle
nullreturns fromGetToken()/GetAccount()anderrorfields in results.
If you encounter any specific issues during migration (for example, ambiguous field mapping or event ordering problems), consider logging the raw structures in your environment to verify the actual data and adjust your migration accordingly.