public void SaveObjectsToFile() { //TODO: Mesh bounds give recursive error on JsonConvert but no on JsonUtilities if (_editableObjects.Count <= 0) { return; } List <ObjectEditableData> objData = new List <ObjectEditableData>(); List <string> data = new List <string>(); foreach (var obj in _editableObjects) { objData.Add(obj.GetComponent <MenuObjectControl>().EditableData); } var json = JsonConvert.SerializeObject(objData.ToArray()); BasicIO.SaveToFile(json, FileName, ".json"); }
public void LoadObjectsFromFile() { var json = BasicIO.ReadFromFile(FileName, ".json"); if (json.Equals("")) { return; } var deserialize = JsonConvert.DeserializeObject <List <ObjectEditableData> >(json); foreach (var data in deserialize) { foreach (var editObj in _editableObjects) { var obj = editObj.GetComponent <MenuObjectControl>(); if (obj.EditableData.GUID.Equals(data.GUID)) { obj.EditableData = data; obj.SetEditableDataToObject(); break; } } } }