Skip to content

Commit 590b72d

Browse files
committed
📝 updated README-Unity.md code examples with new naming convention
1 parent 20fcaef commit 590b72d

1 file changed

Lines changed: 38 additions & 38 deletions

File tree

README-Unity.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LSL.cs includes a Unity interface to liblsl as a [Unity native plug-in](https://
2020
1. When the cube is selected, in the Inspector click on "Add Component", and create a new script called LSLInput.
2121
1. In the Project viewer, double click on LSLInput.cs. This should launch Visual Studio or another IDE.
2222
1. Fill in the script. Use [LSL4Unity AInlet](https://github.com/labstreaminglayer/LSL4Unity/blob/master/Scripts/AInlet.cs) for inspiration.
23-
* There is [currently a bug](https://github.com/sccn/liblsl/issues/29) that prevents liblsl in Unity from resolving streams from _other_ computers while running in editor, and also the built product but only when using `ContinuousResolver`. For this reason we recommend using `liblsl.resolve_stream` instead.
23+
* There is [currently a bug](https://github.com/sccn/liblsl/issues/29) that prevents liblsl in Unity from resolving streams from _other_ computers while running in editor, and also the built product but only when using `ContinuousResolver`. For this reason we recommend using `LSL.resolve_stream` instead.
2424

2525
```cs
2626
using System.Collections;
@@ -32,19 +32,19 @@ public class LSLInput : MonoBehaviour
3232
{
3333
public string StreamType = "EEG";
3434
public float scaleInput = 0.1f;
35-
liblsl.StreamInfo[] streamInfos;
36-
liblsl.StreamInlet streamInlet;
35+
LSL.StreamInfo[] streamInfos;
36+
LSL.StreamInlet streamInlet;
3737
float[] sample;
3838
private int channelCount = 0;
3939

4040
void Update()
4141
{
4242
if (streamInlet == null)
4343
{
44-
streamInfos = liblsl.resolve_stream("type", StreamType, 1, 0.0);
44+
streamInfos = LSL.LSL.resolve_stream("type", StreamType, 1, 0.0);
4545
if (streamInfos.Length > 0)
4646
{
47-
streamInlet = new liblsl.StreamInlet(streamInfos[0]);
47+
streamInlet = new LSL.StreamInlet(streamInfos[0]);
4848
channelCount = streamInlet.info().channel_count();
4949
streamInlet.open_stream();
5050
}
@@ -79,41 +79,41 @@ public class LSLInput : MonoBehaviour
7979

8080
1. Attach a new component called LSLPosOutput to the cube.
8181
1. Edit it as follows:
82-
```cs
83-
using System.Collections;
84-
using System.Collections.Generic;
85-
using UnityEngine;
86-
using LSL;
82+
```cs
83+
using System.Collections;
84+
using System.Collections.Generic;
85+
using UnityEngine;
86+
using LSL;
8787

88-
public class LSLOutput : MonoBehaviour
89-
{
90-
private liblsl.StreamOutlet outlet;
91-
private float[] currentSample;
88+
public class LSLOutput : MonoBehaviour
89+
{
90+
private LSL.StreamOutlet outlet;
91+
private float[] currentSample;
9292

93-
public string StreamName = "Unity.ExampleStream";
94-
public string StreamType = "Unity.StreamType";
95-
public string StreamId = "MyStreamID-Unity1234";
93+
public string StreamName = "Unity.ExampleStream";
94+
public string StreamType = "Unity.StreamType";
95+
public string StreamId = "MyStreamID-Unity1234";
9696

97-
// Start is called before the first frame update
98-
void Start()
99-
{
100-
liblsl.StreamInfo streamInfo = new liblsl.StreamInfo(StreamName, StreamType, 3, Time.fixedDeltaTime * 1000, liblsl.channel_format_t.cf_float32);
101-
liblsl.XMLElement chans = streamInfo.desc().append_child("channels");
102-
chans.append_child("channel").append_child_value("label", "X");
103-
chans.append_child("channel").append_child_value("label", "Y");
104-
chans.append_child("channel").append_child_value("label", "Z");
105-
outlet = new liblsl.StreamOutlet(streamInfo);
106-
currentSample = new float[3];
107-
}
97+
// Start is called before the first frame update
98+
void Start()
99+
{
100+
LSL.StreamInfo streamInfo = new LSL.StreamInfo(StreamName, StreamType, 3, Time.fixedDeltaTime * 1000, LSL.channel_format_t.cf_float32);
101+
LSL.XMLElement chans = streamInfo.desc().append_child("channels");
102+
chans.append_child("channel").append_child_value("label", "X");
103+
chans.append_child("channel").append_child_value("label", "Y");
104+
chans.append_child("channel").append_child_value("label", "Z");
105+
outlet = new LSL.StreamOutlet(streamInfo);
106+
currentSample = new float[3];
107+
}
108108

109-
// Update is called once per frame
110-
void FixedUpdate()
111-
{
112-
Vector3 pos = gameObject.transform.position;
113-
currentSample[0] = pos.x;
114-
currentSample[1] = pos.y;
115-
currentSample[2] = pos.z;
116-
outlet.push_sample(currentSample);
117-
}
109+
// Update is called once per frame
110+
void FixedUpdate()
111+
{
112+
Vector3 pos = gameObject.transform.position;
113+
currentSample[0] = pos.x;
114+
currentSample[1] = pos.y;
115+
currentSample[2] = pos.z;
116+
outlet.push_sample(currentSample);
118117
}
119-
```
118+
}
119+
```

0 commit comments

Comments
 (0)