Advertisement
voropserg

Totem Legacy Record JSON example

Feb 7th, 2023 (edited)
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1.     public class LegacyRecord
  2.     {
  3.         public string title;
  4.         public string description; //This property will be shown in the Explorer
  5.         public int highScore;
  6.         public bool gameCompleted;
  7.         public string characterClass;
  8.     }
  9.  
  10.  
  11.     public void SaveLegacyRecord()
  12.     {
  13.         LegacyRecord legacyRecord = new LegacyRecord()
  14.         {
  15.             title = "Game stats",
  16.             description = "Completed the game, hight score of 1337, loves bread",
  17.             highScore = 1337,
  18.             gameCompleted = true,
  19.             characterClass = "Rogue"
  20.         };
  21.  
  22.         string legacyJson = JsonUtility.ToJson(legacyRecord);
  23.  
  24.         tCore.AddLegacyRecord(asset, TotemAssetType.avatar, legacyJson, (recordedLegacy) =>
  25.         {
  26.             Debug.Log("Legacy record added");
  27.         });
  28.     }
  29.  
  30.     public void ReadLegacyRecord()
  31.     {
  32.         tCore.GetLegacyRecords(asset, TotemAssetType.avatar, (retrievedLegacyRecords) =>
  33.         {
  34.             LegacyRecord legacyRecord = JsonUtility.FromJson<LegacyRecord>(retrievedLegacyRecords[0].data);
  35.  
  36.             Debug.Log(legacyRecord.description);
  37.         }, "gameAddress");
  38.  
  39.     }
  40.  
Tags: totem
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement