Advertisement
notwelshman

EOSUnlockAchievement

Mar 22nd, 2024 (edited)
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | Source Code | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. using UnityEngine;
  6. using UnityEngine.EventSystems;
  7. using UnityEngine.UI;
  8.  
  9. #if ENABLE_INPUT_SYSTEM
  10. using UnityEngine.InputSystem;
  11. #endif
  12.  
  13. using Epic.OnlineServices;
  14. using Epic.OnlineServices.Achievements;
  15. using Epic.OnlineServices.Ecom;
  16. using Epic.OnlineServices.UI;
  17. using Epic.OnlineServices.Stats;
  18.  
  19. using PlayEveryWare.EpicOnlineServices;
  20. using PlayEveryWare.EpicOnlineServices.Samples;
  21.  
  22. public class EOSUnlockAchievement : MonoBehaviour
  23. {
  24. private EOSAchievementManager achievementManager;
  25. private EOSLeaderboardManager statManager;
  26.  
  27. private void Awake()
  28. {
  29. var achievementManager = EOSManager.Instance.GetOrCreateManager<EOSAchievementManager>();
  30. var statManager = EOSManager.Instance.GetOrCreateManager<EOSLeaderboardManager>();
  31. }
  32.  
  33. public void UnlockAchievement(string achievementID)
  34. {
  35. achievementManager = EOSManager.Instance.GetOrCreateManager<EOSAchievementManager>();
  36. achievementManager.UnlockAchievementManually(achievementID);
  37. Debug.Log("Epic achievement unlocked");
  38. }
  39.  
  40. public void IncrementStat(string whichStat, int howMuch)
  41. {
  42. statManager = EOSManager.Instance.GetOrCreateManager<EOSLeaderboardManager>();
  43. // The different types of stat on Epic are:
  44. // SUM: adds the value in 'howMuch' to the existing stat total
  45. // MAX: takes whichever is bigger from either 'howMuch' or the existing stat
  46. // MIN: takes whichever is smaller from either 'howMuch' or the existing stat
  47. // LATEST: cannot be used for achievements
  48. statManager.IngestStat(whichStat, howMuch);
  49. Debug.Log("Epic stat updated");
  50. }
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement