Achievements

First of all, make sure that you have filled achievements info under the plugin editor settings.

Windows → Ultimate Mobile → Edit Settings

 

Show achievements UI by using the method bellow:

UM_GameServiceManager.instance.ShowAchievementsUI();

 

The Achievement progress can be reported with following methods:
 

UM_GameServiceManager.instance.UnlockAchievement(TEST_ACHIEVEMENT_1_ID);

//Or for incremental Achievement
UM_GameServiceManager.instance.IncrementAchievement(TEST_ACHIEVEMENT_2_ID, 20f);

 

In IOS there are no such things as incremental achievements, every achievement has percentage of completions from 0 to 100. But in Android we can specify the exact number of steps which the achievement has. And the Android Play Service UI will show the percentage which depends on the current steps to completed steps ratio. Since UM_GameServiceManager is supposed to be the cross-platform solution, it will work the same as IOS achievements. It means that you need to set the completed percentage of achievements, and UM_GameServiceManager will calculate required completed step quantity from android automatically. The following snippet will show the implementation of IncrementAchievement method inside UM_GameServiceManager

public void IncrementAchievement(string id,  float percentages) {
    IncrementAchievement(UltimateMobileSettings.Instance.GetAchievementById(id), percentages);
}


public void IncrementAchievement(UM_Achievement achievement, float percentages) {
    switch(Application.platform) {
    case RuntimePlatform.IPhonePlayer:
        GameCenterManager.submitAchievement(percentages, achievement.IOSId);
        break;
    case RuntimePlatform.Android:

        GPAchievement a = GooglePlayManager.instance.GetAchievement(achievement.AndroidId);
        if(a != null) {
            if(a.type == GPAchievementType.TYPE_INCREMENTAL) {
                int steps = Mathf.CeilToInt((a.totalSteps / 100f) * percentages);
                GooglePlayManager.instance.IncrementAchievementById(achievement.AndroidId, steps);
            } else {
                GooglePlayManager.instance.UnlockAchievementById(achievement.AndroidId);
            }
        }
        break;
    }
}

 

 

The current Achievement progress can be retrieved with the following functions:

public float GetAchievementProgress(string id)
public float GetAchievementProgress(UM_Achievement achievement)

 

You can use UM_Achievement object from the plugin settings.

public class UM_Achievement  {
	public string id {get;}

	public bool IsIncremental {get;}
	public string IOSId {get;}
	public string AndroidId {get;}
	
}

 

The UM_Achievement object is stored in plugin settings and can be obtained with the help of following methods:

public UM_Achievement GetAchievementById(string id)
public UM_Achievement GetAchievementByIOSId(string id)
public UM_Achievement GetAchievementByAndroidId(string id)

 

Example:

UM_Achievement achievement = UltimateMobileSettings.Instance.GetAchievementById("my_achievement_id")


 

You can also reset player's achievements progress for testing purposes:

UM_GameServiceManager.instance.ResetAchievements();

 

The full API use example can be founded under the UM_GameServiceBasics example scene.