public void SaveBombs() { // Create a new data structure for our saving. Bomb_Data data = new Bomb_Data(); // Save the data. data.bombAmount = bombAmount; // Turn the data into Json data. string bombToJson = JsonUtility.ToJson(data); // Save this information. PlayerPrefs.SetString("Bombs", bombToJson); }
private void LoadBombs() { // Get the encrypted information. string bombJson = PlayerPrefs.GetString("Bombs"); // IF we have a null or empty string. if (String.IsNullOrEmpty(bombJson)) { // We do nothing. return; } // Cast the Json data to our Bomb_Data. Bomb_Data data = JsonUtility.FromJson <Bomb_Data> (bombJson); // Set the amount of bombs we have. bombAmount = data.bombAmount; }