Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public static void UnlockLevel (int level)
  2. {
  3. if (level <= Application.levelCount - 1)
  4. {
  5. PlayerPrefs.SetInt(LEVEL_KEY + level.ToString(), 1);//Use 1 for true
  6. }
  7. else
  8. {
  9. Debug.LogError("Trying to unlock level not in build order");
  10. }
  11. }
  12.  
  13. public static bool IsLevelUnlocked (int level)
  14. {
  15. int levelValue = PlayerPrefs.GetInt(LEVEL_KEY + level.ToString());
  16. bool isLevelUnlocked = (levelValue == 1);
  17.  
  18. if (level <= Application.levelCount - 1)
  19. {
  20. return isLevelUnlocked;
  21. }
  22. else
  23. {
  24. Debug.LogError("Trying to query level not in build order");
  25. return false;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement