Ejemplo n.º 1
0
    /// <summary>
    /// Duplicates the UI element.
    /// </summary>
    public void DuplicateUI()
    {
        ExperimentDesignUI designUI = FindObjectOfType <ExperimentDesignUI> ();

        if (designUI != null)
        {
            designUI.AddTrialUI(TrialType, GetTrialData());
        }
    }
Ejemplo 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);
            }
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Called once on the first frame. Sets up the saved tests directory if it doesn't exist,
    /// then calls DontDestroyOnLoad() to persist through scene changes. Registers OnTrialLoaded
    /// to the scene loaded event.
    /// </summary>
    public void Awake()
    {
        if (!Directory.Exists(Application.dataPath + SAVED_TESTS))
        {
            Directory.CreateDirectory(Application.dataPath + SAVED_TESTS);
        }

        if (!Directory.Exists(Application.dataPath + SAVED_RESULTS))
        {
            Directory.CreateDirectory(Application.dataPath + SAVED_RESULTS);
        }

        ExperimentDesignUI = FindObjectOfType <ExperimentDesignUI> ();

        SerializerSettings = new Newtonsoft.Json.JsonSerializerSettings();
        SerializerSettings.TypeNameHandling = Newtonsoft.Json.TypeNameHandling.Auto;

        DontDestroyOnLoad(this);
        SceneManager.sceneLoaded += OnSceneLoaded;
        CurrentTrial              = 0;
        ExperimentResults         = new List <TrialManager.TrialResults> ();
    }
Ejemplo n.º 4
0
 /// <summary>
 /// Sets the ExperimentDesignUI, updates the RemoveTrialButton to remove the trial.
 /// </summary>
 /// <param name="parentUI">The ExperimentDesignUI holding this TrialDesignUI.</param>
 public void SetParentUI(ExperimentDesignUI parentUI)
 {
     ExperimentDesignUI = parentUI;
     RemoveTrialButton.onClick.AddListener(delegate { ExperimentDesignUI.RemoveTrialUI(this); });
 }