preferences fixes and dropdown styles

This commit is contained in:
ntr committed 2022-04-01 14:08:47 +11:00
1 parent 464d39321e
commit 70ab364c08
9 files changed
+1792 -2164

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
using System.IO;
using UnityEngine;
[System.Serializable]
public class PreferenceData {
// Preference Fields
public int themeIndex;
// Others
string _path;
public PreferenceData(string path) {
_path = path;
themeIndex = 0;
}
public PreferenceData Load() {
try {
string json = File.ReadAllText(_path);
JsonUtility.FromJsonOverwrite(json, this);
return this;
} catch {
// file doesn't exist yet
return Save();
}
}
public PreferenceData Save() {
File.WriteAllText(_path, JsonUtility.ToJson(this));
return this;
}
}
public interface IPreferenceData {
PreferenceData LoadPreferences();
PreferenceData SavePreferences();
}