Files
ichni_Official/Assets/Scripts/Settings/SettingsManager.cs

60 lines
1.5 KiB
C#
Raw Normal View History

2025-08-11 14:04:06 -04:00
using Ichni.Menu;
2025-06-06 10:14:55 -04:00
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.Serialization;
namespace Ichni
{
public class SettingsManager : SerializedMonoBehaviour
{
public static SettingsManager instance;
2025-08-11 14:04:06 -04:00
[FormerlySerializedAs("settingsPage")]
public SettingsUIPage settingsUIPage;
2025-06-06 10:14:55 -04:00
public GameSettings gameSettings;
private void Awake()
{
2025-08-11 14:04:06 -04:00
if (instance == null)
{
instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
2025-06-06 10:14:55 -04:00
}
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(
2025-08-11 14:04:06 -04:00
50, 50, 50, 50,
2026-01-12 03:19:38 -05:00
0, 60, 3, 0, false, false);
2025-06-06 10:14:55 -04:00
}
2025-08-11 14:04:06 -04:00
gameSettings.ApplyVolume();
gameSettings.ApplyGraphic();
2025-06-06 10:14:55 -04:00
}
}
}