- Home /
When I call achievement and leaderboard from GREE platform game stuck for few seconds. How to resolve this issue please help me.
We used sandbox application and my code is given below.
using UnityEngine;
using System.Collections;
using UnityEngine.SocialPlatforms;
using System.Threading;
public class MyClass : MonoBehaviour {
private Gree.User localUser;
private Gree.Achievement _achi;
string id ;
string userName;
private string _result;
// Use this for initialization
void Start () {
}
void Update() {
}
// Authentication for GREE platform
public void Login()
{
Gree.Authorizer.Login ((Gree.User user) => {
Debug.Log ( "Login OK : User ID = " + user.id);
PlayerPrefs.SetString("UserID",user.id);
PlayerPrefs.SetString("Authenticated","True");
} , (string message) => {
Debug.Log ( "Login error: " + message);
} );
}
//to save score to achivement
public void SaveAchivement(int achiv_index)
{
if (Gree.Authorizer.IsAuthorized()) {
Gree.Achievement.LoadAchievements(1, 0xFFFF, (IAchievement[] achievements) => {
this._achi = (Gree.Achievement)achievements[achiv_index];
this._achi.percentCompleted = 100.0;
this._achi.ReportProgress((bool success) => {
} );
} );
}
}
}
when I call SaveAchivement() from another script below, Then the game got stucked for few seconds.Is it possible to call this on background.
var plScript: AndroidPluginConnecter;
function Start () {
plScript = new AndroidPluginConnecter();
}
function OnCollisionEnter (collision : Collision) {
plScript.SaveAchivement(14);
}
Read this page : http://answers.unity3d.com/page/newuser.html
For any help, please format your code. You can do this by highlighting all your code, then clicking the 10101 button at the top of the edit window.
Watch : http://video.unity3d.com/video/7720450/tutorials-using-unity-answers
I have formatted this one for you. Please check the code is correct.
Your answer
Follow this Question
Related Questions
Game Froze, No Inputs 0 Answers
PostLateUpdate.PlayerUpdateCanvases issue 2 Answers
Import Componet ( Variable ) Error Unexpected Token 3 Answers
FPS Animations for head and arms 0 Answers
Target frame rate between scenes 1 Answer