forked from cgvr/DeltaVR
trellis and invokeAI urls configurable in config
This commit is contained in:
39
Assets/_PROJECT/Scripts/ModeGeneration/ConfigManager.cs
Normal file
39
Assets/_PROJECT/Scripts/ModeGeneration/ConfigManager.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConfigManager : MonoBehaviour
|
||||
{
|
||||
public GameConfig Config { get; private set; }
|
||||
public static ConfigManager Instance { get; private set; }
|
||||
private static string configPath => Path.Combine(Application.persistentDataPath, "config.json");
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
LoadConfig();
|
||||
}
|
||||
|
||||
public void LoadConfig()
|
||||
{
|
||||
if (File.Exists(configPath))
|
||||
{
|
||||
string json = File.ReadAllText(configPath);
|
||||
Config = JsonUtility.FromJson<GameConfig>(json);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create config with default values
|
||||
Config = new GameConfig();
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
Debug.Log("Loaded config from: " + configPath);
|
||||
}
|
||||
|
||||
public void SaveConfig()
|
||||
{
|
||||
string json = JsonUtility.ToJson(Config, true);
|
||||
File.WriteAllText(configPath, json);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user