60 lines
1.5 KiB
C#
60 lines
1.5 KiB
C#
using Ichni.Menu;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace Ichni
|
|
{
|
|
public class SettingsManager : SerializedMonoBehaviour
|
|
{
|
|
public static SettingsManager instance;
|
|
|
|
[FormerlySerializedAs("settingsPage")]
|
|
public SettingsUIPage settingsUIPage;
|
|
public GameSettings gameSettings;
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
LoadGameSettings();
|
|
}
|
|
|
|
[Button]
|
|
public void SaveGameSettings()
|
|
{
|
|
string savePath = Application.persistentDataPath + "/GameData/GameSettings.json";
|
|
ES3.Save("GameSettings", gameSettings, savePath);
|
|
}
|
|
|
|
[Button]
|
|
public void LoadGameSettings()
|
|
{
|
|
string savePath = Application.persistentDataPath + "/GameData/GameSettings.json";
|
|
if (ES3.FileExists(savePath))
|
|
{
|
|
gameSettings = ES3.Load<GameSettings>("GameSettings", savePath);
|
|
}
|
|
else
|
|
{
|
|
gameSettings = new GameSettings(
|
|
50, 50, 50, 50,
|
|
0, 60, 3, 0, false);
|
|
}
|
|
|
|
gameSettings.ApplyVolume();
|
|
gameSettings.ApplyGraphic();
|
|
}
|
|
}
|
|
} |