private void AwardThirdPartyAchievements(string in_achievements) { #if !(DOT_NET) // only do it for logged in players if (!UnityEngine.Social.localUser.authenticated) { Debug.Log("Couldnt award Unity Social achievement because localUser was not authenticated"); return; } IAchievement achievement = UnityEngine.Social.CreateAchievement(); achievement.id = in_achievements; achievement.percentCompleted = 100.0; //progress as double achievement.ReportProgress(result => { if (result) { Debug.Log("AwardThirdPartyAchievements Success"); } else { Debug.Log("AwardThirdPartyAchievements Failed"); } }); #endif }
private void AwardThirdPartyAchievements(string in_achievements) { #if !(DOT_NET) // only do it for logged in players UnityEngine.Social.localUser.Authenticate(success => { if (success) { IAchievement achievement = UnityEngine.Social.CreateAchievement(); achievement.id = in_achievements; achievement.percentCompleted = 100.0; //progress as double achievement.ReportProgress(result => { if (result) { Console.Write("AwardThirdPartyAchievements Success"); } else { Console.Write("AwardThirdPartyAchievements Failed"); } }); } }); #endif }
public override void ReportProgress(Action <bool> _onCompletion) { base.ReportProgress(_onCompletion); if (Description == null) { return; } // Report progress to GameCenter m_achievementData.ReportProgress(OnReportProgressFinished); }
public void UnlockAchivement(string id) { //PlayGamesPlatform.Instance.UnlockAchievement(id, (bool success) => { // handle success or failure //}); IAchievement achievement = Social.CreateAchievement(); achievement.id = id; achievement.percentCompleted = 100.0; achievement.ReportProgress(result => { if (result) { Debug.Log("Successfully reported progress"); } else { Debug.Log("Failed to report progress"); } }); }
/// <summary> /// 実績の進捗状況を送信する /// </summary> public static void ReportProgress(string achievementKey, float percent, Action <bool> callBack = null) { //アチーブメントのインスタンスを作成し、keyと進捗率を設定 IAchievement achievement = Social.CreateAchievement(); achievement.id = achievementKey; achievement.percentCompleted = percent; //コールバックが設定されていない場合はログを設定 if (callBack == null) { callBack = (success) => { Debug.Log(success ? "進捗送信成功" : "進捗送信失敗"); }; } //エディター上で送信すると、エラーが出るので、送信が成功したことにする #if UNITY_EDITOR callBack(true); #else //送信 achievement.ReportProgress(callBack); #endif }