public void Import(ScriptableObject scriptableObject) { if (this.settings == null) { return; } string file = ImportExportHelper.PersistentPath(scriptableObject.name + ".json"); if (this.settings.CustomDirectory) { string source = ImportExportHelper.AbsolutePath(this.settings.DirectoryPath, scriptableObject.name + ".json"); ImportExportHelper.CopyFile(source, file); } if (ImportExportHelper.ExistsFile(file)) { string json = ImportExportHelper.ImportFile(file); JsonUtility.FromJsonOverwrite(json, scriptableObject); LogNow(ImportExportLogType.Import, scriptableObject); } else { Export(scriptableObject); } }
private void WriteLog() { if (!this.settings.WriteLog) { return; } if (this.logs.Count < 1) { return; } List <string> lines = new List <string>(); foreach (ImportExportLog log in this.logs) { lines.Add(log.ToLog()); } ImportExportHelper.LogLines(ImportExportHelper.PersistentPath(logFile), lines); }
public void Export(ScriptableObject scriptableObject) { if (this.settings == null) { return; } string json = JsonUtility.ToJson(scriptableObject, true); string file = ImportExportHelper.PersistentPath(scriptableObject.name + ".json"); ImportExportHelper.ExportFile(file, json); if (this.settings.CustomDirectory) { file = ImportExportHelper.AbsolutePath(this.settings.DirectoryPath, scriptableObject.name + ".json"); ImportExportHelper.BackupFile(file); ImportExportHelper.ExportFile(file, json); } LogNow(ImportExportLogType.Export, scriptableObject); }
public string ReadLogTail(int n = 1) { return(ImportExportHelper.ReadFileTail(ImportExportHelper.PersistentPath(logFile), n)); }
public void ClearLogFile() { ImportExportHelper.DeleteFile(ImportExportHelper.PersistentPath(logFile)); }