From 813decd292e3cbe07e8cca6b7f4899934d276834 Mon Sep 17 00:00:00 2001 From: "BCOM\\nchambron" <nathan.chambron@b-com.com> Date: Mon, 8 Aug 2022 17:37:53 +0200 Subject: [PATCH] fix: removed error when saving link with unreferenced connected elements --- .../Editor/Windows/GraphEditorWindow.cs | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/GraphEditorWindow.cs b/Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/GraphEditorWindow.cs index 36c691b..e203bfd 100644 --- a/Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/GraphEditorWindow.cs +++ b/Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/GraphEditorWindow.cs @@ -1015,25 +1015,34 @@ namespace Assets.ETSI.ARF.ARF_World_Storage_API.Editor.Windows } //save button + + //if one of the connected elements is not in the server, you can't save the link if (GUILayout.Button("Save")) { - if (SaveInfo.instance.linkIds.Contains(worldLink.UUID.ToString())) - { - if (EditorUtility.DisplayDialog("Saving element", "Are you sure you want to save this element in the server ?", "Yes", "No")) + if ((SaveInfo.instance.nodePositions.ContainsKey(worldLink.UUIDTo.ToString()) && SaveInfo.instance.nodePositions.ContainsKey(worldLink.UUIDFrom.ToString()))) + { + if (SaveInfo.instance.linkIds.Contains(worldLink.UUID.ToString())) + { + if (SaveInfo.instance.elemsToUpdate.Contains(worldLink.UUID.ToString())) + { + WorldLinkRequest.UpdateWorldLink(SaveInfo.instance.worldStorageServer, worldLink); + SaveInfo.instance.elemsToUpdate.Remove(worldLink.UUID.ToString()); + } + } + else { - WorldLinkRequest.UpdateWorldLink(SaveInfo.instance.worldStorageServer, worldLink); - SaveInfo.instance.elemsToUpdate.Remove(worldLink.UUID.ToString()); + String uuid = WorldLinkRequest.AddWorldLink(SaveInfo.instance.worldStorageServer, worldLink); + + //Add the newly saved WorldLink to the SaveInfo singleton + uuid = uuid.Replace("\"", ""); + worldLink.UUID = Guid.Parse(uuid); + worldLinkEdge.GUID = uuid; + SaveInfo.instance.linkIds.Add(uuid); } } else { - String uuid = WorldLinkRequest.AddWorldLink(SaveInfo.instance.worldStorageServer, worldLink); - - //Add the newly saved WorldLink to the SaveInfo singleton - uuid = uuid.Replace("\"", ""); - worldLink.UUID = Guid.Parse(uuid); - worldLinkEdge.GUID = uuid; - SaveInfo.instance.linkIds.Add(uuid); + EditorUtility.DisplayDialog("Error", "You are not able to save this link because at least one of its connected elements is not saved in the World Storage", "Ok"); } } GUILayout.Space(10); -- GitLab