Advertisement
HowTEYT

...

Jun 18th, 2022
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. List<string> Inventory = new List<string>();
  2.  
  3. void Start()
  4. {
  5. for (int i = 0; i < 8; i++)
  6. {
  7. Inventory.Add(PlayerPrefs.GetString("Inventory" + i));
  8. Debug.Log(PlayerPrefs.GetString("Inventory" + i));
  9. Debug.Log("Inventory" + i);
  10. }
  11. Debug.Log(Inventory[1]);
  12. }
  13.  
  14. public void AddItem(string item)
  15. {
  16. Debug.Log(item);
  17. Inventory.Add(item);
  18. Debug.Log(Inventory[0]);
  19. }
  20.  
  21. void Update()
  22. {
  23. if (Input.GetKeyDown(KeyCode.F5))
  24. {
  25. Debug.Log(Inventory[0]);
  26. Debug.Log("Saved");
  27.  
  28. for (int i = 0; i < Inventory.Count; i++)
  29. {
  30. PlayerPrefs.SetString("Inventory" + i, Inventory[i]);
  31. Debug.Log("Inventory" + i);
  32. PlayerPrefs.Save();
  33. }
  34. Debug.Log(Inventory);
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement