public override bool SaveChanges() { if (activeLayer == null) { return(false); } bool updateBackend = false; Site activeSite = null; if (properties.name.HasChanged) { activeLayer.ChangeName(properties.name); updateBackend = true; } if (properties.group.HasChanged) { activeLayer.ChangeGroup(properties.group); updateBackend = true; } if (properties.color.HasChanged) { activeLayer.ChangeColor(properties.color); updateBackend = true; } if (updateBackend) { dataManagerPanel.UpdateActiveLayer(); if (!dataManagerPanel.UpdateBackend()) { return(false); } } #if !UNITY_WEBGL if (properties.site.HasChanged || properties.year.HasChanged || properties.units.HasChanged || properties.categories.HasChanged || properties.coloring.HasChanged || properties.metadata.HasChanged) { var originalSiteName = properties.site.OriginalValue; var site = dataManager.GetSite(originalSiteName); if (properties.site.HasChanged) { // Move layer to another site var newSite = dataManager.GetOrAddSite(properties.site); site.MoveLayerToSite(activeLayer, newSite); activeSite = site = newSite; } if (properties.year.HasChanged) { activeLayer.ChangeYear(properties.year.OriginalValue, properties.year, site); } if (properties.units.HasChanged || properties.categories.HasChanged || properties.coloring.HasChanged || properties.metadata.HasChanged) { var directories = dataManager.GetDataDirectories(); var binFiles = activeLayer.GetPatchFiles(directories, site.Name, Patch.BIN_EXTENSION); int count = binFiles.Count; for (int i = 0; i < count; ++i) { var file = binFiles[i]; var newFile = file + ".new"; try { if (File.Exists(newFile)) { File.Delete(newFile); } IntCategory[] categories = null; if (properties.categories.Value != null) { categories = properties.categories.Value.OfType <IntCategory>().ToArray(); } GridDataIO.UpdateBin(file, newFile, properties.units, properties.coloring, properties.metadata, categories); File.Delete(file); File.Move(newFile, file); } catch (Exception e) { Debug.LogException(e); } } } } #endif properties.Apply(); if (activeSite != null) { dataManagerPanel.RefreshSiteList(activeSite); } return(true); }