Has anyone run into an issue on iOS where after showing the leaderboards the user can press the done button when the game center screen appears very quickly and cause a crash? I'm using Unity's Social API and am having a tough time figuring out what's causing the crash. I don't believe it's in the code I wrote but here's how I'm interfacing with the social API:
public class SocialData : MonoBehaviour
{
private static SocialData instance;
private const string leaderboardId = "RemovingTheActualLeaderboardId";
UnityEngine.SocialPlatforms.ILeaderboard leadboard;
public static SocialData Instance
{
get
{
if(instance == null)
{
instance = (MonoBehaviour.Instantiate(Resources.Load(string.Format ("Prefabs/SocialData"))) as GameObject).GetComponent();
}
return instance;
}
}
private void Awake()
{
if(instance == null)
{
instance = this;
DontDestroyOnLoad(this);
}
else
{
DestroyImmediate(this);
}
}
private void Start()
{
Social.localUser.Authenticate(this.AuthenticateCallback);
}
void AuthenticateCallback (bool success)
{
if(success)
{
Debug.Log ("Authentication successful");
this.leadboard = Social.CreateLeaderboard();
this.leadboard.id = leaderboardId;
this.leadboard.LoadScores(this.LoadScoresCallback);
}
else
{
Debug.Log ("Authentication failed!!!");
}
}
void LoadScoresCallback (bool success)
{
if(success)
{
Debug.Log ("score loaded successful");
}
else
{
Debug.Log ("score loaded failed");
}
}
void ReportScoreCallback (bool success)
{
if(success)
Debug.Log("score submission successful");
else
Debug.Log("score submission failed");
}
public void ProcessScore(int score)
{
Social.ReportScore(score,leaderboardId,this.ReportScoreCallback);
}
public void LoadLeaderboard ()
{
Social.ShowLeaderboardUI();
}
}
Edit: I've upgraded to Unity 5.2 and tried again without any impact on my issue. I'm still seeing the game crash when hitting done as the leaderboard appears.
↧