fix some confilict

This commit is contained in:
lwj
2025-05-29 09:37:14 +09:00
parent d6199f8c39
commit 01106d7256
2 changed files with 128 additions and 30 deletions

View File

@@ -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<SaveLoadmanager>();
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<LogicQueue> queues)
{

View File

@@ -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<SimulationModel>(FindObjectsSortMode.None);
List<SimulationModelInfo> saveInfos = new List<SimulationModelInfo>();
@@ -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<SimulationModelInfo> loadInfos = new List<SimulationModelInfo>();
loadInfos = JsonConvert.DeserializeObject<List<SimulationModelInfo>>(jsonData);
@@ -113,9 +108,9 @@ public class SaveLoadmanager : MonoBehaviour
Dictionary<string, SimulationModel> loadModels = new Dictionary<string, SimulationModel>();
foreach(var item in loadInfos)
foreach (var item in loadInfos)
{
var simulationModel = Resources.Load<GameObject>(string.Format("{0}/{1}", resourcePath, item.prefabName));
var spawnItem = Instantiate(simulationModel).GetComponent<SimulationModel>();
@@ -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<SimulationModel>(FindObjectsSortMode.None);
// List<SimulationModelInfo> saveInfos = new List<SimulationModelInfo>();
// 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<WebModelReturnClass>(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<WebModelReturnClass>(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<SimulationModelInfo> loadInfos = new List<SimulationModelInfo>();
// loadInfos = JsonConvert.DeserializeObject<List<SimulationModelInfo>>(jsonData);
// string resourcePath = "Models";
// Dictionary<string, SimulationModel> loadModels = new Dictionary<string, SimulationModel>();
// foreach(var item in loadInfos)
// {
// var simulationModel = Resources.Load<GameObject>(string.Format("{0}/{1}", resourcePath, item.prefabName));
// var spawnItem = Instantiate(simulationModel).GetComponent<SimulationModel>();
// 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;