Jörn Alexander Quent's notebook

where I share semi-interesting stuff from my work

How to change UXF’s start up menu using a .json input file

In my last post a while back, I showed how to load a .json file in to Unity3D without using UXF, which if you can do this, is still the easiest way for experiments. One of the problems with UXF however is that you cannot access the .json file before starting UXF’s session, which is exactly the problem that I ran into here. Let me explain:

One thing that bothered me was that the start up menu generated by UXF is hardcoded meaning that you have to change it in the Unity3D editor even for only small changes like for instance changing the instructions. This is why I wrote this neat little script that allows you to configure the start-up menu as you see it above.

All that you need to do to get this start-up menu is to a) attach the script to any game object, b) copy the corresponding .json file into the StreamingAssets folder and c) provide the file name to th script.

The example .json file to create the start up menu above:

{
    "chromeBar": "Startup",
    "instructionsPanelContent1": "Welcome to OLM task! ",
    "instructionsPanelContent2": "You could use this space to display some instructions to the researcher or the participant.",
    "expSettingsprofile": "Experiment settings profile",
    "localPathElement": "Local data save directory",
    "localPathElement_placeHolder": "Press browse button to select...",
    "participantID": "Participant ID",
    "participantID_placeholder": "Enter text...",
    "sessionNumber": "Session number",
    "termsAndConditions": "Please tick if you understand the instructions and agree for your data to be collected and used for research purposes.<color=red>*</color>",
    "beginButton": "Begin session."
}

With this small trick you can always edit the menu of your completed build without opening Unity3D again.

Note: You need to set-up all variables that you want to get from the .json file. The variable names have to correspond to the input names in that file. If you want a different layout with additional things like another dropdown menu you’ll have to adapt the code & the .json file.

I have been using this script in all my latest tasks and it serves as a teaser for what is to come.


Share