• The get API is used for retrieving a user’s saved data.
  • You should store the retrieved data from Get Api callback to your unity variables/Playerprefs.
  • Example, if “Lives” key retrieves value “10” using Get Api, then you must save it in local variables that you are using in your code to save life of user and hence load game level. PlayerPrefs.SetInt(“Life”, keyValuePair.Value);
  • IdnetSample.cs has more examples of Get API usage.

Get a Class ‘UserProgressExampleData’:

Idnet.I.Get<UserProgressExampleData>("UserProgress", (keyValuePair, getException) => {
 if (getException != null)
    Debug.Log("Get failed for '" + keyValuePair.Key + "'");
    Debug.Log("Probably no data on server,so load the game level here");
     Debug.Log("Retrieved '"+keyValuePair.Key+"' with value '"+keyValuePair.Value);
     Debug.Log("Example UserProgress: "
  	 + "\n" + keyValuePair.Value.NumOfLevelsUnlocked
  	 + "\n" + keyValuePair.Value.TotalCoins
  	 + "\n" + keyValuePair.Value.Lives
  	 + "\n" + keyValuePair.Value.MaxDistanceTravelled
  	 + "\n" + keyValuePair.Value.UnlockedCharacterName
  	 + "\n" + keyValuePair.Value.IsTutorialCompleted

   Debug.Log("Save retrieved values to playerprefs and hence load the game level");

UserProgressExampleData Class:

  • Example class, create your own class as per usage.
internal class UserProgressExampleData
  public int NumOfLevelsUnlocked;
  public int TotalCoins;
  public int Lives;
  public float MaxDistanceTravelled;
  public string UnlockedCharacterName;
  public bool IsTutorialCompleted;
  public UserProgressExampleData(int numlevels, int totalcoins, int lives,float maxdistance,string charactername,bool istutorialcompleted)
	NumOfLevelsUnlocked = numlevels;
	TotalCoins = totalcoins;
	Lives = lives;