private void OnIdentityChanged(object err, UnitySocialCredential result) { if (err != null) { throw new CredentialException("Identity change with error: " + err); } if (result.isAnonymous) { _local.ChangeToAnonymousIdentityId(result.userId + "_" + result.projectId); } }
public void OnIdentityChanged(string data) { var dict = Tools.DictionaryExtensions.JsonToDictionary(data); UnitySocialCredential credential = null; object projectId, userId, accessToken, userName, isAnonymous, callbackId; string error = null; if (dict.TryGetValue("projectId", out projectId) && dict.TryGetValue("userId", out userId) && dict.TryGetValue("isAnonymous", out isAnonymous) && dict.TryGetValue("accessToken", out accessToken) && dict.TryGetValue("userName", out userName)) { credential = new UnitySocialCredential(); credential.projectId = (string)projectId; credential.userId = (string)userId; credential.token = (string)accessToken; credential.username = (string)userName; credential.isAnonymous = (bool)isAnonymous; } else { error = "Message from js was:\"" + data + "\""; } Identity unitySocialIdentity = Identity.defaultProvider as Identity; if (unitySocialIdentity != null) { if (dict.TryGetValue("callbackId", out callbackId)) { unitySocialIdentity.CallGetOrRefreshCredentialAsyncCallback(Convert.ToUInt32(callbackId), error, credential); } else { unitySocialIdentity.SetCredential(error, credential); } } }