preferences fixes and dropdown styles
This commit is contained in:
1 parent
464d39321e
commit
70ab364c08
9 files changed
+1792
-2164
No files matched your search
@@ -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();
|
||||
}
|
||||
Reference in new issue
Block a user