internal iOSAchievement(string _identifier) { m_achievementData = Social.CreateAchievement(); Identifier = _identifier; }
static void LoadAchievements() { if (instance.namesAndIDs.Length == 0) { return; } #if UNITY_ANDROID // make the null stuff not null string[] keysStr = new string[achievements.Count]; achievements.Keys.CopyTo(keysStr, 0); for (int i = 0; i < keysStr.Length; i++) { IAchievement newAchievement = Social.CreateAchievement(); newAchievement.id = keysStr[i]; newAchievement.percentCompleted = (double)PlayerPrefs.GetFloat(Social.localUser.id + keysStr[i], 0.0f); achievements[keysStr[i]] = newAchievement; } #elif UNITY_IOS // only returns completed or in progress achievements Social.LoadAchievements(achs => { if (achs.Length > 0) { for (int i = 0; i < achs.Length; i++) { IAchievement achievement = achs[i]; achievements[achs[i].id] = achievement; } } // make the null stuff not null string[] keysStr = new string[achievements.Count]; achievements.Keys.CopyTo(keysStr, 0); for (int i = 0; i < keysStr.Length; i++) { float localSaveValue = PlayerPrefs.GetFloat(Social.localUser.id + keysStr[i], 0.0f); if (achievements[keysStr[i]] == null) { IAchievement newAchievement = Social.CreateAchievement(); newAchievement.id = keysStr[i]; newAchievement.percentCompleted = (double)localSaveValue; achievements[keysStr[i]] = newAchievement; } else if (achievements[keysStr[i]].percentCompleted < localSaveValue) { if (localSaveValue >= 100.0) { Achievement_Unlock(keysStr[i]); } else { achievements[keysStr[i]].percentCompleted = (double)localSaveValue; } } } }); #endif }