Skip to content
Snippets Groups Projects
Commit f93f76c4 authored by Kabourlix-PC's avatar Kabourlix-PC
Browse files

json export has been corrected and work

parent 3df5608a
No related branches found
No related tags found
No related merge requests found
......@@ -39,8 +39,8 @@ namespace SequenceLogic
}
[Serializable]
public struct IterationSavedData
public class IterationSavedData
{
public List<IterationSavedSettings> savedSettings;
public List<IterationSavedSettings> savedSettings = new List<IterationSavedSettings>();
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ namespace SequenceLogic
{
public class SequenceModel
{
private const string ExportPath = "Scripts\\DataExport";
private const string ExportPath = "/Scripts/DataExport";
#region Iteration Related Variables
......@@ -49,7 +49,7 @@ namespace SequenceLogic
private void End()
{
//We export the data
var files = Directory.GetFiles(Tools.JsonParser<int>.GetPathRight() + "\\" + ExportPath);
var files = Directory.GetFiles(Tools.JsonParser<int>.GetPathRight() + ExportPath);
ExportExperimentSettings("experiment" + files.Length+".json"); //get a proper name for the exported file
}
......
using System;
using SequenceLogic;
using UnityEngine;
using Random = UnityEngine.Random;
/// <summary>
/// Class for testing some stuffs.
/// </summary>
public class Test : MonoBehaviour
{
private IterationSavedData _export;
private int[] _order;
private void Start()
{
_export = new IterationSavedData();
_order = new[] {4, 2, 1, 3, 0};
for (var i = 0; i < 5; i++)
{
var added = new IterationSavedSettings
{
duration = UnityEngine.Random.Range(0.1f, 15f),
iterationIndex = _order[i]
};
_export.savedSettings.Add(added);
}
print("Out of the for loop.");
Tools.JsonParser<IterationSavedData>.ExportToJson(_export,"","test.json");
print("After the save file call.");
}
}
fileFormatVersion: 2
guid: 39ed53606f0a4b33a660ebf6136e07f5
timeCreated: 1653316605
\ No newline at end of file
......@@ -8,7 +8,7 @@ namespace Tools
{
public static T ParseFile(string file)
{
var jsonString = File.ReadAllText(GetPath() + "\\" + file);
var jsonString = File.ReadAllText(GetPath() + "/" + file);
return JsonUtility.FromJson<T>(jsonString);
}
......@@ -20,7 +20,8 @@ namespace Tools
//Open the file to write to (try at least)
try
{
var file = File.CreateText(GetPathRight() + "\\" +directory + "\\" + filename);
Debug.Log("The path on which the file is written is " + GetPathRight() +directory + "/" + filename);
var file = File.CreateText(GetPathRight() +directory + "/" + filename);
file.Write(jsonString);
file.Close(); //Close the file
}
......
{"savedSettings":[{"duration":2.1723475456237795,"iterationIndex":4},{"duration":4.711724758148193,"iterationIndex":2},{"duration":0.6678765416145325,"iterationIndex":1},{"duration":14.539254188537598,"iterationIndex":3},{"duration":1.7028168439865113,"iterationIndex":0}]}
\ No newline at end of file
fileFormatVersion: 2
guid: 120eea7ca48008849b5b416c5f8e546b
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment