PlayerData.cs 416 B

12345678910111213141516171819202122
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayerData : MonoBehaviour
  5. {
  6. private int _playerLevel;
  7. public int GetLevel => _playerLevel;
  8. private void Awake()
  9. {
  10. _playerLevel = PlayerPrefs.GetInt("_playerLevel");
  11. }
  12. public void AddLevel()
  13. {
  14. _playerLevel++;
  15. PlayerPrefs.SetInt("_playerLevel", _playerLevel);
  16. }
  17. }