From 01106d725672e925eea869035c6b345ab300d829 Mon Sep 17 00:00:00 2001 From: lwj Date: Thu, 29 May 2025 09:37:14 +0900 Subject: [PATCH] fix some confilict --- .../LH/LogicData/LogicDataManager.cs | 24 +--- Assets/WorkSpace/LWJ/SaveLoadmanager.cs | 134 ++++++++++++++++-- 2 files changed, 128 insertions(+), 30 deletions(-) diff --git a/Assets/WorkSpace/LH/LogicData/LogicDataManager.cs b/Assets/WorkSpace/LH/LogicData/LogicDataManager.cs index 5734a9da..3e277f1b 100644 --- a/Assets/WorkSpace/LH/LogicData/LogicDataManager.cs +++ b/Assets/WorkSpace/LH/LogicData/LogicDataManager.cs @@ -92,26 +92,14 @@ namespace Octopus.Simulator void GetDataFromInfo(LogicData Data) { - Debug.Log("what"); - currentData = Data; config = Data.webConfig; - if (currentData.ModelFiles.Count >= 1) - { - SimulationModelFile files = currentData.ModelFiles[currentData.ModelFiles.Count-1]; - if (files.id.HasValue) - { - WebParameters.config.modelId = files.id.Value.ToString(); - var saveload = FindAnyObjectByType(); - saveload.Onclick_Load(files.data.info); - } - } - QueueVisulization(Data.data.queues); - ResourceVisulization(Data.data.resources); - StoreVisulization(Data.data.stores); - ComponentVisulization(Data.data.components); - ConnectEdge(); - } + QueueVisulization(Data.data.queues); + ResourceVisulization(Data.data.resources); + StoreVisulization(Data.data.stores); + ComponentVisulization(Data.data.components); + ConnectEdge(); + } void QueueVisulization(List queues) { diff --git a/Assets/WorkSpace/LWJ/SaveLoadmanager.cs b/Assets/WorkSpace/LWJ/SaveLoadmanager.cs index 2283a6c4..533d9f80 100644 --- a/Assets/WorkSpace/LWJ/SaveLoadmanager.cs +++ b/Assets/WorkSpace/LWJ/SaveLoadmanager.cs @@ -20,11 +20,9 @@ public class SaveLoadmanager : MonoBehaviour { } - - public void Onclick_Save() { - var path = StandaloneFileBrowser.SaveFilePanel("Save Layout", "", "", ""); + //var path = StandaloneFileBrowser.SaveFilePanel("Save Layout", "", "", ""); var simulationModels = FindObjectsByType(FindObjectsSortMode.None); List saveInfos = new List(); @@ -32,9 +30,6 @@ public class SaveLoadmanager : MonoBehaviour foreach (var item in simulationModels) { - if (item is SimulationModelProduct) - continue; - var tmpSimulationModelInfo = new SimulationModelInfo(); tmpSimulationModelInfo.prefabName = item.gameObject.name.Replace("(Clone)", ""); @@ -87,7 +82,7 @@ public class SaveLoadmanager : MonoBehaviour byte[] buffer = Encoding.UTF8.GetBytes(jsonObject); fileStream.Write(buffer, 0, buffer.Length); fileStream.Close(); - + */ } @@ -103,7 +98,7 @@ public class SaveLoadmanager : MonoBehaviour string jsonData = Encoding.UTF8.GetString(data); */ - + List loadInfos = new List(); loadInfos = JsonConvert.DeserializeObject>(jsonData); @@ -113,9 +108,9 @@ public class SaveLoadmanager : MonoBehaviour Dictionary loadModels = new Dictionary(); - foreach(var item in loadInfos) + foreach (var item in loadInfos) { - + var simulationModel = Resources.Load(string.Format("{0}/{1}", resourcePath, item.prefabName)); var spawnItem = Instantiate(simulationModel).GetComponent(); @@ -128,14 +123,129 @@ public class SaveLoadmanager : MonoBehaviour spawnItem.gameObject.transform.localScale = ParseVector3(item.scale); spawnItem.gameObject.transform.rotation = ParseQuaternion(item.rotation); - if ( !string.IsNullOrEmpty(item.nodeID)) - loadModels.Add(item.nodeID, spawnItem); + if (!string.IsNullOrEmpty(item.nodeID)) + loadModels.Add(item.nodeID, spawnItem); } LogicMappingDataBase.LoadDataBase(loadModels); } + + //public void Onclick_Save() + //{ + // var path = StandaloneFileBrowser.SaveFilePanel("Save Layout", "", "", ""); + // var simulationModels = FindObjectsByType(FindObjectsSortMode.None); + + // List saveInfos = new List(); + + + // foreach (var item in simulationModels) + // { + // if (item is SimulationModelProduct) + // continue; + + // var tmpSimulationModelInfo = new SimulationModelInfo(); + + // tmpSimulationModelInfo.prefabName = item.gameObject.name.Replace("(Clone)", ""); + // tmpSimulationModelInfo.modelName = item.modelName; + // tmpSimulationModelInfo.modelType = item.modelType; + // tmpSimulationModelInfo.modelID = item.modelID; + // tmpSimulationModelInfo.nodeID = item.nodeID; + // tmpSimulationModelInfo.position = item.transform.position.ToString(); + // tmpSimulationModelInfo.rotation = item.transform.rotation.ToString(); + // tmpSimulationModelInfo.scale = item.transform.localScale.ToString(); + + // saveInfos.Add(tmpSimulationModelInfo); + // } + + // string jsonObject = JsonConvert.SerializeObject(saveInfos, Formatting.Indented); + + // var modelClass = new WebModelClass(); + // modelClass.logicId = int.Parse(WebParameters.config.logicId); + // modelClass.name = "new model"; + // modelClass.description = "new model"; + // modelClass.data.info = jsonObject; + + // string requestAPI = $"{WebManager.webManager.apiConfig.model}"; + // Debug.Log(requestAPI); + // if (string.IsNullOrEmpty(WebParameters.config.modelId)) + // { + // WebManager.webManager.Request_Post(modelClass, requestAPI, (flag, value) => + // { + // if (flag) + // { + // var webreturnClass = JsonConvert.DeserializeObject(value); + // WebParameters.config.modelId = webreturnClass.data.insertedId.ToString(); + // } + // }); + // } + // else + // { + // WebManager.webManager.Request_Put(modelClass, $"{requestAPI}/{WebParameters.config.modelId}", (flag, value) => + // { + // if (flag) + // { + // var webreturnClass = JsonConvert.DeserializeObject(value); + // WebParameters.config.modelId = webreturnClass.data.insertedId.ToString(); + // } + // }); + // } + // /* + // FileStream fileStream = new FileStream(string.Format("{0}.json", path), FileMode.Create); + + // byte[] buffer = Encoding.UTF8.GetBytes(jsonObject); + // fileStream.Write(buffer, 0, buffer.Length); + // fileStream.Close(); + + + //} + + //public void Onclick_Load(string jsonData) + //{ + // /* + // var path = StandaloneFileBrowser.OpenFilePanel("Open Layout", "", "", false); + + // FileStream fileStream = new FileStream(string.Format("{0}", path), FileMode.Open); + // byte[] data = new byte[fileStream.Length]; + // fileStream.Read(data, 0, data.Length); + // fileStream.Close(); + + // string jsonData = Encoding.UTF8.GetString(data); + // */ + + // List loadInfos = new List(); + + // loadInfos = JsonConvert.DeserializeObject>(jsonData); + + + // string resourcePath = "Models"; + + // Dictionary loadModels = new Dictionary(); + + // foreach(var item in loadInfos) + // { + + // var simulationModel = Resources.Load(string.Format("{0}/{1}", resourcePath, item.prefabName)); + // var spawnItem = Instantiate(simulationModel).GetComponent(); + + // spawnItem.modelName = item.modelName; + // spawnItem.modelType = item.modelType; + // spawnItem.modelID = item.modelID; + // spawnItem.nodeID = item.nodeID; + + // spawnItem.gameObject.transform.position = ParseVector3(item.position); + // spawnItem.gameObject.transform.localScale = ParseVector3(item.scale); + // spawnItem.gameObject.transform.rotation = ParseQuaternion(item.rotation); + + // if ( !string.IsNullOrEmpty(item.nodeID)) + // loadModels.Add(item.nodeID, spawnItem); + // } + + // LogicMappingDataBase.LoadDataBase(loadModels); + //} + + public Vector3 ParseVector3(string input) { Vector3 returnValue;