|
|
|
using Newtonsoft.Json;
|
|
|
|
using System.IO;
|
|
|
|
using UnityEngine;
|
|
|
|
using AX.MessageSystem;
|
|
|
|
|
|
|
|
public class GameManager : Singleton<GameManager>
|
|
|
|
{
|
|
|
|
// Start is called before the first frame update
|
|
|
|
public override void Initialize()
|
|
|
|
{
|
|
|
|
base.Initialize();
|
|
|
|
//AssetManager.Instance.Initialize();
|
|
|
|
UIManager.Instance.Initialize();
|
|
|
|
LoadConfig();
|
|
|
|
}
|
|
|
|
public static void SaveConfig()
|
|
|
|
{
|
|
|
|
|
|
|
|
ConfigWebGL webConfig = new ConfigWebGL() { ServerAddress = Config.ServerAddress, BucketName = Config.BucketName, AreaName = Config.AreaName, CompanyName = Config.CompanyName };
|
|
|
|
|
|
|
|
string json = JsonConvert.SerializeObject(webConfig, Formatting.Indented);
|
|
|
|
string path = Path.Combine(Application.streamingAssetsPath, "Config.json");
|
|
|
|
|
|
|
|
using (StreamWriter streamWriter = File.CreateText(path))
|
|
|
|
{
|
|
|
|
streamWriter.Write(json);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static void LoadConfig()
|
|
|
|
{
|
|
|
|
string path = Path.Combine(Application.streamingAssetsPath, "Config.json");
|
|
|
|
UnityNetworkManager.Instance.Get(path, (b, json) =>
|
|
|
|
{
|
|
|
|
if (b)
|
|
|
|
{
|
|
|
|
Debug.Log("================================================================" + json);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ConfigWebGL webConfig = JsonConvert.DeserializeObject<ConfigWebGL>(json);
|
|
|
|
Config.ServerAddress = webConfig.ServerAddress;
|
|
|
|
Config.BucketName = webConfig.BucketName;
|
|
|
|
Config.AreaName = webConfig.AreaName;
|
|
|
|
Config.CompanyName = webConfig.CompanyName;
|
|
|
|
Config.LocationServer = webConfig.LocationServer;
|
|
|
|
Config.AlarmServer = webConfig.AlarmServer;
|
|
|
|
Config.PersonnelVideoUrl = webConfig.PersonnelVideoUrl;
|
|
|
|
Config.Tags = webConfig.Tags;
|
|
|
|
Config.Range = webConfig.Range;
|
|
|
|
Config.Interval = webConfig.Interval;
|
|
|
|
Config.MapId = webConfig.MapId;
|
|
|
|
Config.AlarmServer = webConfig.AlarmServer;
|
|
|
|
Config.AlarmInterval = webConfig.AlarmInterval;
|
|
|
|
Debug.Log("ServerAddress:" + Config.ServerAddress + " Interval:" + Config.Interval + " Range:" + Config.Range);
|
|
|
|
MessageDispatcher.SendMessage("ConfigLoadOver");
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|