This is a v0.0.1 bootstrap. It does one thing: connect to a PiEEG-server over WebSocket and hand you raw EEG frames in C#. That's it.
Not yet included (planned, contributions welcome):
- Band powers (δ/θ/α/β/γ) computed in-engine
- Smoothed / normalized signals (alpha level, focus, relaxation as
floatin [0,1])- Per-band
UnityEvent<float>for inspector wiring- Demo scene / sample assets
- Typed wrappers for server commands (recording, filter, OSC, LSL)
- Authentication flow (
--authmode).metafiles / verified UPM publishIf you need any of the above today, use the raw WebSocket API directly — it's documented in the PiEEG-server README.
Born from a Discord discussion with the community about whether a Unity SDK was worth shipping. Consensus: yes, but start small. So here we are.
In Unity, open Window → Package Manager → + → Install package from git URL… and paste:
https://github.com/pieeg-club/PiEEG-unity.git?path=/Packages/com.pieeg.unity
Requires Unity 2021.3 LTS or newer. No third-party dependencies (uses System.Net.WebSockets.ClientWebSocket).
Add a PiEEGStream component to any GameObject, set Url to ws://raspberrypi.local:1616, leave Connect On Start ticked, and wire the On Frame Event UnityEvent in the inspector.
Or in code:
using PiEEG.Unity;
using UnityEngine;
public class BrainDemo : MonoBehaviour
{
public PiEEGStream stream;
void OnEnable() => stream.OnFrame += HandleFrame;
void OnDisable() => stream.OnFrame -= HandleFrame;
void HandleFrame(PiEEGFrame frame)
{
// frame.channels is µV per channel (8 or 16 elements).
// frame.t = unix seconds, frame.n = monotonic sample index.
float ch0 = frame.channels[0];
transform.localScale = Vector3.one * (1f + Mathf.Abs(ch0) * 0.001f);
}
}That's the whole API surface for v0.0.1.
See the "Not yet included" list above. Issues and PRs welcome — especially for band-power computation and a proper demo scene.
MIT — see LICENSE.