Skip to content
Markus edited this page Oct 11, 2016 · 12 revisions

Welcome to the LSL4Unity wiki!

Labstreaminglayer is a data acquisition and synchronization framework for distributed systems with focus on reliability, near-realtime access and time-synchronization. Developed and maintained by Christian A. Kothe at Swartz Center for Computational Neuroscience, University of California San Diego, it's primarily used for scientific experiments in the domain of eeg-based neuroscience and brain-computer-interface research.

For Details on LSL please see the Google code page (maybe deprecated), the GitHub repository or the excellent introduction on Youtube. Youtube

Due to requirements of Virtual Reality supported Neuroscience this repository provides a first implementation of LSL for the Unity3D Game Engine.

Getting Started

Using the Asset package

Due to the early stage of development their is no asset package available on the asset store. Use this github repository instead by either downloading the latest master branch as a zip file or cloning the master branch into a directory with the Name LSL4Unity directly under_ Assets/_

So finally, in your project, it should look like:

Assets/LSL4Unity/

Assets/LSL4Unity/LSL.cs

Assets/LSL4Unity/REAMDME.md

Assets/LSL4Unity/lib

Assets/LSL4Unity/lib/liblsl32.dll

...

Using a Marker Stream

To use the Marker Stream either drag the LabStreamingLayer.prefab into your scene or attach the LSLMarkerStream script to a GameObject and use it from one of your scripts.

using Assets.LSL4Unity.Scripts; // reference the namespace to get access to all classes

public class ElementWritingMarker: MonoBehaviour
{
    private LSLMarkerStream marker;

    void Start()
    {
        renderer = GetComponent<MeshRenderer>();

        marker = FindObjectOfType<LSLMarkerStream>();
    }

    public void OnCollisionEnter(Collision collision)
    {
        marker.Write("Collision on " + this.name); 
    }
}

Important if you want to use the Marker Stream for recording data for later analysis in EEG/MoBI/BCILAB. Change the Property StreamName of your instantiated LSLMarkerStream component to markers - all Toolboxes expects that.

Quickstart Recieving data eg. floats

Instantiate the ExampleFloatInlet on a GameObject in your scene and change either the StreamName or the StreamType to the value corresponding to the stream you want to recieve. Press Start and take a look at the Last Sample property. The values of incoming samples should appear.