/// <summary> /// Sets the Current Experiment data, then loads the first trial scene. /// </summary> /// <param name="experimentName">The name of the current experiment setup (for saving results)</param> /// <param name="participantId">The current participant ID (for saving results)</param> public void StartExperiment(string experimentName, string participantId) { CurrentExperimentName = experimentName; CurrentParticipantId = participantId; CurrentExperiment = ExperimentDesignUI.GetExperimentData(); ExperimentResults.Clear(); LoadTrial(CurrentExperiment.ExperimentTrials [CurrentTrial]); }
/// <summary> /// Displays an OpenFilePanel, then loads the selected experiment file. /// </summary> public void LoadExperiment() { string[] files = SFB.StandaloneFileBrowser.OpenFilePanel("Load Experiment", Application.dataPath + SAVED_TESTS, TEST_EXTENTION, false); if (files != null && files.Length > 0 && files[0] != null) { CurrentExperimentName = GetNameFromPath(files [0]); string fileData = File.ReadAllText(files[0]); ExperimentSave experiment = Newtonsoft.Json.JsonConvert.DeserializeObject <ExperimentSave> (fileData, SerializerSettings); ExperimentDesignUI.ClearUI(); ExperimentDesignUI.SetExperiment(experiment); ExperimentDesignUI.SetExperimentName(CurrentExperimentName); } }
/// <summary> /// Collects the ExperimentData from the ExperimentDesignUI, then writes them to a file. /// </summary> public void SaveExperiment() { CurrentExperiment = ExperimentDesignUI.GetExperimentData(); string experimentJSON = Newtonsoft.Json.JsonConvert.SerializeObject(CurrentExperiment, SerializerSettings); string filePath = SFB.StandaloneFileBrowser.SaveFilePanel("Save Experiment", Application.dataPath + SAVED_TESTS, CurrentExperimentName, TEST_EXTENTION); if (filePath != "") { File.WriteAllText(filePath, experimentJSON); CurrentExperimentName = GetNameFromPath(filePath); ExperimentDesignUI.ClearUI(); ExperimentDesignUI.SetExperimentName(CurrentExperimentName); ExperimentDesignUI.SetExperiment(CurrentExperiment); } }