Exemplo n.º 1
0
    /// <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);
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Called when a scene is loaded. Currently, looks for a TrialManager and passes it
    /// the TrialJSON for initialization. If no TrialManager is found, assumes is in menu
    /// and rebuilds UI for current trial setup.
    /// </summary>
    /// <param name="trialScene"></param>
    /// <param name="loadMode"></param>
    private void OnSceneLoaded(Scene trialScene, LoadSceneMode loadMode)
    {
        TrialManager manager = FindObjectOfType <TrialManager> ();

        if (manager != null)
        {
            manager.InitializeTrials(CurrentExperiment.ExperimentTrials [CurrentTrial].TrialData);
        }
        else
        {
            ExperimentDesignUI = FindObjectOfType <ExperimentDesignUI> ();
            if (ExperimentDesignUI != null)
            {
                ExperimentDesignUI.SetExperiment(CurrentExperiment);
                ExperimentDesignUI.SetParticipantId(CurrentParticipantId);
                ExperimentDesignUI.SetExperimentName(CurrentExperimentName);
            }
        }
    }