40 lines
968 B
C#
40 lines
968 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Newtonsoft.Json;
|
|
using UnityEngine;
|
|
|
|
namespace BITKit
|
|
{
|
|
[Serializable]
|
|
public class ScriptableObjectConfig:IConfigProvider
|
|
{
|
|
[SerializeField] private ConfigScriptableObject so;
|
|
public string GetConfig(params object[] args)=>so.GetConfig(args);
|
|
public void Configure(params object[] args)
|
|
{
|
|
so.Configure(args);
|
|
}
|
|
}
|
|
public class ConfigScriptableObject : ScriptableObject,IConfigProvider
|
|
{
|
|
[SerializeField] private AYellowpaper.SerializedCollections.SerializedDictionary<string, string> data;
|
|
|
|
public string GetConfig(params object[] args)
|
|
{
|
|
var x = data.ToDictionary<KeyValuePair<string, string>, string, object>(y => y.Key, y => y.Value);
|
|
return JsonConvert.SerializeObject(x);
|
|
}
|
|
|
|
public void Configure(params object[] args)
|
|
{
|
|
foreach (var pair in data)
|
|
{
|
|
BITCommands.Excute($"set {pair.Key} {pair.Value}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|