51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Ichni.UI;
|
|
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()
|
|
{
|
|
instance = this;
|
|
}
|
|
|
|
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(
|
|
100, 100, 100, 100,
|
|
0, 60, false, false);
|
|
}
|
|
}
|
|
}
|
|
} |