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 36c691b1ed39c0ffaf56114d84d4a818d958cff5..e203bfd89b5d8974f324920c6c82b4149495ddc2 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);