Skip to content

🛠️Integration & Event Subscription

Martin Feick edited this page Dec 11, 2020 · 2 revisions

1. Import SteamVR and Vive Input Utility assets (if you haven't already)

2. Drag VivePointers Prefab into your scene

VivePointer

3. Drag VRQuestionnaireToolkit Prefab into your scene

VivePointer

The package generates all required components based on the specified .json file when running the scene. You can dis-/enable the questionnaires on demand by accessing the questionnairelist using the following code. That's all it takes =)

    private GameObject _vrQuestionnaireToolkit;
    private GenerateQuestionnaire _generateQuestionnaire;

    void Start()
    {
        _vrQuestionnaireToolkit = GameObject.FindGameObjectWithTag("VRQuestionnaireToolkit");
        _generateQuestionnaire = _vrQuestionnaireToolkit.GetComponentInChildren<GenerateQuestionnaire>();
    }

    void Demonstrate()
    {
         _generateQuestionnaire.Questionnaires[0].SetActive(false); // disable questionnaire 0
         _generateQuestionnaire.Questionnaires[1].SetActive(true); // enable questionnaire 1
    }

Subscribe to questionnaire events (sends an event after pressing the "Submit" button)

   private ExportToCSV _exportToCsvScript;
   private GameObject _exportToCsv;
         
   void Start()
   {
       _exportToCsv = GameObject.FindGameObjectWithTag("ExportToCSV");
       _exportToCsvScript = _exportToCsv.GetComponent<ExportToCSV>();
       _exportToCsvScript.QuestionnaireFinishedEvent.AddListener(YourFunction); // e.g, call next questionnaire from list
   }