From 72d03050d9f90071fa19a897bd4b29aef1d481dc Mon Sep 17 00:00:00 2001 From: YDL <1368269699@qq.com> Date: Tue, 16 Apr 2024 10:16:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E6=9C=AA=E7=BB=91=E5=AE=9A=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8F=98=E6=9B=B4,=E5=8A=A0=E8=BD=BD=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=94=BE=E5=9C=A8=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=AE=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/ANet/DeviceObjManager.cs | 22 ++++++++++++++++------ Assets/Scripts/ANet/DevicePanelManager.cs | 17 ++++++++++++++--- Assets/Scripts/Common/GameManager.cs | 18 ++++++++++-------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/Assets/Scripts/ANet/DeviceObjManager.cs b/Assets/Scripts/ANet/DeviceObjManager.cs index 78ca439..00e2ef4 100644 --- a/Assets/Scripts/ANet/DeviceObjManager.cs +++ b/Assets/Scripts/ANet/DeviceObjManager.cs @@ -1,3 +1,4 @@ +using AX.MessageSystem; using Newtonsoft.Json; using System; using System.Collections; @@ -22,8 +23,21 @@ public class DeviceObjManager : MonoBehaviour private void Awake() { + MessageDispatcher.AddListener("ConfigLoadOver", ConfigLoadOver); Instance = this; } + private void Start() + { + + } + private void OnDestroy() + { + MessageDispatcher.RemoveListener("ConfigLoadOver", ConfigLoadOver); + } + private void ConfigLoadOver(IMessage obj) + { + LoadDeviceObjs(); + } private void Update() { if (Input.GetKey(KeyCode.Q)) @@ -48,10 +62,6 @@ public class DeviceObjManager : MonoBehaviour } } } - private void Start() - { - LoadDeviceObjs(); - } public DeviceObj GetDeviceByName(string dname) { DeviceObj result = null; @@ -118,7 +128,7 @@ public class DeviceObjManager : MonoBehaviour public void SaveObjs() { var json = JsonConvert.SerializeObject(NowPointList); - string url = string.Format(HttpManager.Instance.PostBreakPointsById, objId); + string url = string.Format(HttpManager.Instance.PostIOilTankById, objId); if (Application.platform == RuntimePlatform.WebGLPlayer) { url = url.Substring(url.IndexOf("api") - 1); @@ -133,7 +143,7 @@ public class DeviceObjManager : MonoBehaviour { try { - string url = string.Format(HttpManager.Instance.GetBreakPointsById, objId); + string url = string.Format(HttpManager.Instance.GetOilTankById, objId); Debug.Log($"the url is :{ url}"); if (Application.platform == RuntimePlatform.WebGLPlayer) { diff --git a/Assets/Scripts/ANet/DevicePanelManager.cs b/Assets/Scripts/ANet/DevicePanelManager.cs index cbaf7aa..da98e20 100644 --- a/Assets/Scripts/ANet/DevicePanelManager.cs +++ b/Assets/Scripts/ANet/DevicePanelManager.cs @@ -9,6 +9,7 @@ using System.Security.Cryptography; using System.IO; using UnityEngine.Networking; using UnityEngine.EventSystems; +using AX.MessageSystem; #region 接口数据类型 #pragma warning disable IDE1006 // 命名样式 @@ -263,13 +264,23 @@ public class DevicePanelManager : MonoBehaviour #endregion void Awake() { + MessageDispatcher.AddListener("ConfigLoadOver", ConfigLoadOver); Instance = this; } private void Start() + { + + } + private void OnDestroy() + { + MessageDispatcher.RemoveListener("ConfigLoadOver", ConfigLoadOver); + } + private void ConfigLoadOver(IMessage obj) { LoadDeciceData(); LoadDeviceObjConfig(); } + public void RefreshData() { StopAllCoroutines(); @@ -626,7 +637,7 @@ public class DevicePanelManager : MonoBehaviour { try { - string url = string.Format(HttpManager.Instance.GetBreakPointsById, objId); + string url = string.Format(HttpManager.Instance.GetOilTankById, objId); Debug.Log($"the url is :{ url}"); if (Application.platform == RuntimePlatform.WebGLPlayer) { @@ -673,7 +684,7 @@ public class DevicePanelManager : MonoBehaviour DeviceObjManager.Instance.AddObj(bindName); } var json = JsonConvert.SerializeObject(BindObjectList); - string url = string.Format(HttpManager.Instance.PostBreakPointsById, objId); + string url = string.Format(HttpManager.Instance.PostIOilTankById, objId); if (Application.platform == RuntimePlatform.WebGLPlayer) { url = url.Substring(url.IndexOf("api") - 1); @@ -687,7 +698,7 @@ public class DevicePanelManager : MonoBehaviour public void SaveDeviceObjConfig() { var json = JsonConvert.SerializeObject(BindObjectList); - string url = string.Format(HttpManager.Instance.PostBreakPointsById, objId); + string url = string.Format(HttpManager.Instance.PostIOilTankById, objId); if (Application.platform == RuntimePlatform.WebGLPlayer) { url = url.Substring(url.IndexOf("api") - 1); diff --git a/Assets/Scripts/Common/GameManager.cs b/Assets/Scripts/Common/GameManager.cs index 1481d4d..b8dfbbb 100644 --- a/Assets/Scripts/Common/GameManager.cs +++ b/Assets/Scripts/Common/GameManager.cs @@ -1,6 +1,7 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System.IO; using UnityEngine; +using AX.MessageSystem; public class GameManager : Singleton { @@ -14,12 +15,12 @@ public class GameManager : Singleton } public static void SaveConfig() { - - ConfigWebGL webConfig = new ConfigWebGL() {ServerAddress = Config.ServerAddress, BucketName = Config.BucketName, AreaName = Config.AreaName, CompanyName = Config.CompanyName }; - + + 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); @@ -32,7 +33,7 @@ public class GameManager : Singleton { if (b) { - Debug.Log("================================================================"+json); + Debug.Log("================================================================" + json); } else { @@ -49,11 +50,12 @@ public class GameManager : Singleton Config.Interval = webConfig.Interval; Config.AlarmServer = webConfig.AlarmServer; Config.AlarmInterval = webConfig.AlarmInterval; - Debug.Log("ServerAddress:" + Config.ServerAddress+" Interval:"+Config.Interval+" Range:"+Config.Range); + Debug.Log("ServerAddress:" + Config.ServerAddress + " Interval:" + Config.Interval + " Range:" + Config.Range); + MessageDispatcher.SendMessage("ConfigLoadOver"); } }); } - + }