Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SaveManager : MonoBehaviour
- {
- public static SaveManager Instance { get; set; }
- private void Awake()
- {
- if (Instance != null && Instance != this)
- {
- Destroy(gameObject);
- }
- else
- {
- Instance = this;
- }
- DontDestroyOnLoad(gameObject);
- }
- [System.Serializable]
- public class VolumeSettings
- {
- public float music;
- public float effects;
- public float master;
- }
- public void SaveVolumeSettings(float _music, float _effects, float _master)
- {
- VolumeSettings volumeSettings = new VolumeSettings()
- {
- music = _music,
- effects= _effects,
- master = _master
- };
- PlayerPrefs.SetString("Volume", JsonUtility.ToJson(volumeSettings));
- PlayerPrefs.Save();
- print("Saved to Player Pref");
- }
- public VolumeSettings LoadVolumeSettings()
- {
- return JsonUtility.FromJson<VolumeSettings>(PlayerPrefs.GetString("Volume"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement