public static bool Save(MapMeta meta) { try { File.WriteAllText(GetPath(meta.Map.ID), JsonUtility.ToJson(meta)); }catch (System.Exception e) { Debug.LogError(e.Message); return(false); } return(true); }
public static bool Delete(MapMeta meta) { if (!File.Exists(GetPath(meta.Map.ID))) { return(false); } try { File.Delete(GetPath(meta.Map.ID)); }catch (System.Exception e) { Debug.LogError(e.Message); return(false); } return(true); }
public void Save(string name, Optional <easyar.Image> preview) { IsSaving = true; MapWorker.BuilderMapController.MapHost += (map, isSuccessful, error) => { if (isSuccessful) { var mapMeta = new MapMeta(map, new List <MapMeta.PropInfo>()); MapMetaManager.Save(mapMeta); // Maps 添加一个Map /********************************************/ var mapData = new MapData(); mapData.Meta = mapMeta; Maps.Add(mapData); /********************************************/ GUIPopup.EnqueueMessage("Map Generated", 3); GUIPopup.EnqueueMessage("Notice: map name can be changed on website," + Environment.NewLine + "while the SDK side will not get updated until map cache cleared and a re-download has been triggered.", 5); Saved = true; } else { GUIPopup.EnqueueMessage("Fail to generate Map" + (string.IsNullOrEmpty(error) ? "" : "\n error: " + error), 5); } IsSaving = false; }; try { MapWorker.BuilderMapController.Host(name, preview); } catch (Exception e) { GUIPopup.EnqueueMessage("Fail to host map: " + e.Message, 5); IsSaving = false; } }