You've already forked Commercialization.topon
update 1.1.25
This commit is contained in:
105
AnyThinkPlugin/Script/IntegrationManager/Editor/ATConfigAsset.cs
Normal file
105
AnyThinkPlugin/Script/IntegrationManager/Editor/ATConfigAsset.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.Serialization;
|
||||
// using Newtonsoft.Json;
|
||||
|
||||
namespace AnyThink.Scripts.Assets
|
||||
{
|
||||
|
||||
public class ConfigData {
|
||||
public int localCountry = 1;
|
||||
public Dictionary<string, string> installedNetworkVersion = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public class ATConfigAsset
|
||||
{
|
||||
public string filePath = "Assets/AnyThinkPlugin/Resources/ATConfigData.json";
|
||||
|
||||
private static readonly object lockObject = new object(); // 创建一个静态对象作为锁
|
||||
|
||||
private static ATConfigAsset instance;
|
||||
private ConfigData configData;
|
||||
|
||||
private ATConfigAsset() {
|
||||
|
||||
}
|
||||
|
||||
public static ATConfigAsset Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new ATConfigAsset();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
public int getLocalCountry() {
|
||||
getJsonFile();
|
||||
return Instance.configData.localCountry;
|
||||
}
|
||||
|
||||
public void setLocalCountry(int country) {
|
||||
configData.localCountry = country;
|
||||
updateJsonFile();
|
||||
}
|
||||
|
||||
public void saveInstalledNetworkVersion(string key, string version)
|
||||
{
|
||||
configData.installedNetworkVersion[key] = version;
|
||||
ATLog.log("updateJsonFile() >>> saveInstalledNetworkVersion: key = " + key + " version = " + version);
|
||||
updateJsonFile();
|
||||
}
|
||||
|
||||
public void removeInstalledNetworkVersion(string key)
|
||||
{
|
||||
ATLog.log("updateJsonFile() >>> removeInstalledNetworkVersion: key = " + key);
|
||||
if (configData.installedNetworkVersion.ContainsKey(key)) {
|
||||
configData.installedNetworkVersion.Remove(key);
|
||||
}
|
||||
updateJsonFile();
|
||||
}
|
||||
|
||||
public string getInstalledNetworkVersion(string key)
|
||||
{
|
||||
getJsonFile();
|
||||
if (Instance.configData.installedNetworkVersion.ContainsKey(key)) {
|
||||
return Instance.configData.installedNetworkVersion[key];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void updateJsonFile() {
|
||||
// lock(lockObject) {
|
||||
// if (configData == null) {
|
||||
// configData = new ConfigData();
|
||||
// }
|
||||
// string json = JsonConvert.SerializeObject(configData);
|
||||
// System.IO.File.WriteAllText(filePath, json);
|
||||
// ATLog.log("updateJsonFile() >>> json: " + json);
|
||||
// }
|
||||
}
|
||||
|
||||
private void getJsonFile() {
|
||||
// lock(lockObject) {
|
||||
// if (!Directory.Exists(filePath)) {
|
||||
// configData = new ConfigData();
|
||||
// updateJsonFile();
|
||||
// }
|
||||
// string jsonString = System.IO.File.ReadAllText(filePath);
|
||||
// ATLog.log("getJsonFile() >>> jsonString: " + jsonString);
|
||||
// Instance.configData = JsonConvert.DeserializeObject<ConfigData>(jsonString);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user