1
This commit is contained in:
51
Assets/Scripts/Settings/SettingsManager.cs
Normal file
51
Assets/Scripts/Settings/SettingsManager.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user