1
This commit is contained in:
39
Assets/Scripts/Settings/GameSettings.cs
Normal file
39
Assets/Scripts/Settings/GameSettings.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni
|
||||
{
|
||||
public class GameSettings
|
||||
{
|
||||
public int mainVolume = 100;
|
||||
public int backgroundMusicVolume = 100;
|
||||
public int soundEffectVolume = 100;
|
||||
public int uiVolume = 100;
|
||||
|
||||
public int judgeOffset = 0;
|
||||
public int targetFrame = 60;
|
||||
|
||||
public bool lowResolution = false;
|
||||
public bool debugMode = false;
|
||||
|
||||
public GameSettings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public GameSettings(int mainVolume, int backgroundMusicVolume, int soundEffectVolume, int uiVolume,
|
||||
int judgeOffset, int targetFrame, bool lowResolution, bool debugMode)
|
||||
{
|
||||
this.mainVolume = mainVolume;
|
||||
this.backgroundMusicVolume = backgroundMusicVolume;
|
||||
this.soundEffectVolume = soundEffectVolume;
|
||||
this.uiVolume = uiVolume;
|
||||
this.judgeOffset = judgeOffset;
|
||||
this.targetFrame = targetFrame;
|
||||
this.lowResolution = lowResolution;
|
||||
this.debugMode = debugMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Settings/GameSettings.cs.meta
Normal file
11
Assets/Scripts/Settings/GameSettings.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2ca67619927cac4a91d5b0612d6f7eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Settings/SettingsManager.cs.meta
Normal file
11
Assets/Scripts/Settings/SettingsManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49501a5fe129ecf4ca83fd1c5d03411e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user