-
Notifications
You must be signed in to change notification settings - Fork 48
Programming ideas
Jack Brookes edited this page Apr 26, 2021
·
10 revisions
Ideas for getting the most out of UXF
You can hook a method into the On Write File
Event in the FileIOManager component of UXF Rig that copies files to a secondary location.
Even though it can lead to bad programming practices, you may opt to use a "singleton" programming technique to make accessing the UXF Session easier. Here is an example - attach this script to your UXF Rig and it will persist between scenes and be globally accessible with PersistentRigAccess.uxfSession
.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PersistentRigAccess : MonoBehaviour
{
public static UXF.Session uxfSession;
private void Awake()
{
// make sure only one
PersistentRigAccess[] rigs = GameObject.FindObjectsOfType<PersistentRigAccess>();
if (rigs.Length > 1) Destroy(this.gameObject);
DontDestroyOnLoad(this);
uxfSession = GetComponentInChildren<UXF.Session>();
}
}
You can record audio on each trial using Unity's microphone class and then convert to a WAV byte array. Then you can safely store the data after each trial using the trial.SaveBytes()
method:
// method that converts audioclip to wav bytes
byte[] data = WavUtility.FromAudioClip(newClip);
string fname = string.Format("mic_T{0:000}.wav", trial.number);
// save data, automatically puts it in the session folder.
// it will also store the name in the trial_results file for easier referencing during analysis.
trial.SaveBytes(data, fname);
๐ง Core topics
- ๐ Background
- โจ UXF 2.0
- โ๏ธ Compatibility
- ๐ถ๏ธ Oculus Quest Setup
- ๐ญ Concepts
- ๐ ๏ธ Get started
- ๐ Examples
- ๐ฅ๏ธ Built-in UI
- ๐ Session generation
- โฐ Events
- ๐ Data collection
- โ๏ธ Collect custom data
- ๐ Custom Data Handler
- ๐ Remote Data Collection
- ๐๏ธ WebGL DynamoDB setup
- ๐ Processing DynamoDB CSVs
- ๐ซ HTTP Post Setup
- ๐ง Settings system
- ๐๐ฝ Tracker system
- ๐ Logging system
โ ๏ธ Common issues- ๐ผ๏ธ Multi-scene experiments
- ๐บ Videos
- ๐จโ๐ Full written tutorial
- ๐ฆ Asset links
- ๐จโ๐ซ Unity tutorial links
- ๐ Useful code snippets
- ๐ก Programming ideas
- ๐งฎ Example R processing